private AuthenticationResult AcquireAccessTokenAysnc(AzureResource resource) { AuthenticationContext authContext = new AuthenticationContext(_authority, false); var credentials = new ClientCredential(_subscriptionConfig.ClientId, _subscriptionConfig.ClientSecret); return(authContext.AcquireTokenAsync(resource.Resource, credentials).Result); }
public SubscriptionCloudCredentials GetCredentials(AzureResource resource) { if (resource == null) { string message = string.Format("cannot create azure credential due for sub {0} to invalid resource", _subscriptionConfig.SubscriptionId); throw new Exception(message); } var authenticationResult = AcquireAccessTokenAysnc(resource); return(new TokenCloudCredentials(authenticationResult.AccessToken)); }