Created
December 14, 2017 13:43
-
-
Save radu-matei/2e3e0a95640c65b33940f7a9c5ff73e5 to your computer and use it in GitHub Desktop.
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
func getContainerGroupsClient() (containerinstance.ContainerGroupsClient, error) { | |
var containerGroupsClient containerinstance.ContainerGroupsClient | |
oAuthConfig, err := adal.NewOAuthConfig(defaultActiveDirectoryEndpoint, tenantID) | |
if err != nil { | |
return containerGroupsClient, fmt.Errorf("cannot get oAuth configuration: %v", err) | |
} | |
token, err := adal.NewServicePrincipalToken(*oAuthConfig, clientID, clientSecret, defaultResourceManagerEndpoint) | |
if err != nil { | |
return containerGroupsClient, fmt.Errorf("cannot get service principal token: %v", err) | |
} | |
containerGroupsClient = containerinstance.NewContainerGroupsClient(subscriptionID) | |
containerGroupsClient.Authorizer = autorest.NewBearerAuthorizer(token) | |
return containerGroupsClient, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment