Last active
March 29, 2018 16:35
-
-
Save TheoBrigitte/37bb318d0b6ad40f476ec33e6c755356 to your computer and use it in GitHub Desktop.
run with: dep ensure -v && go run azure_issue_935.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"log" | |
"github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2017-09-01/dns" | |
"github.com/Azure/go-autorest/autorest" | |
"github.com/Azure/go-autorest/autorest/adal" | |
"github.com/Azure/go-autorest/autorest/azure" | |
) | |
const ( | |
// Replace those value with your azure credentials | |
clientID = "xxxxxxxxxxxx" | |
clientSecret = "xxxxxxxxxxxx" | |
subscriptionID = "xxxxxxxxxxxx" | |
tenantID = "xxxxxxxxxxxx" | |
) | |
func main() { | |
log.Println("program to reproduce https://github.com/Azure/azure-sdk-for-go/issues/935") | |
oauthConfig, err := adal.NewOAuthConfig(azure.PublicCloud.ActiveDirectoryEndpoint, tenantID) | |
if err != nil { | |
log.Fatal(err) | |
} | |
spt, err := adal.NewServicePrincipalToken(*oauthConfig, clientID, clientSecret, azure.PublicCloud.ResourceManagerEndpoint) | |
if err != nil { | |
log.Fatal(err) | |
} | |
client := dns.NewRecordSetsClient(subscriptionID) | |
client.Authorizer = autorest.NewBearerAuthorizer(spt) | |
ctx := context.Background() | |
// Passing an empty resourceGroupName argument to dns.RecordSetsClient.Get will result into the following error | |
// | |
// adal.NewServicePrincipalToken:dns.RecordSetsClient#Get: Failure responding to request: StatusCode=400 -- \ | |
// Original Error: autorest/azure: Service returned an error. Status=400 Code="InvalidApiVersionParameter" \ | |
// Message="The api-version '2017-09-01' is invalid. \ | |
// The supported versions are '2018-02-01,2018-01-01,2017-12-01,2017-08-01,2017-06-01,2017-05-10,2017-05-01,2017-03-01,2016-09-01,2016-07-01,2016-06-01,2016-02-01,2015-11-01,2015-01-01,2014-04-01-preview,2014-04-01,2014-01-01,2013-03-01,2014-02-26,2014-04'." | |
_, err = client.Get(ctx, "", "myZone", "myRelativeName", dns.NS) | |
log.Fatal(err) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[[constraint]] | |
name = "github.com/Azure/azure-sdk-for-go" | |
version = "v12.1.0-beta" | |
[[constraint]] | |
name = "github.com/Azure/go-autorest" | |
version = "v9.6.0" | |
[prune] | |
unused-packages = true | |
go-tests = true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment