private async Task <IEnumerable <IAzureUserAccountSubscriptionContext> > GetSubscriptionFromServiceAsync(AzureUserAccount userAccount) { CommonUtil.CheckForNull(userAccount, nameof(userAccount)); List <IAzureUserAccountSubscriptionContext> subscriptionList = new List <IAzureUserAccountSubscriptionContext>(); if (userAccount.NeedsReauthentication) { throw new ExpiredTokenException(SR.UserNeedsAuthenticationError); } try { IAzureResourceManager resourceManager = ServiceProvider.GetService <IAzureResourceManager>(); IEnumerable <IAzureUserAccountSubscriptionContext> contexts = await resourceManager.GetSubscriptionContextsAsync(userAccount); subscriptionList = contexts.ToList(); } catch (ServiceExceptionBase) { throw; } catch (Exception ex) { throw new ServiceFailedException(SR.FailedToGetAzureSubscriptionsErrorMessage, ex); } return(subscriptionList); }
public AzureServerDatabaseDiscoveryProvider(IAzureResourceManager azureResourceManager, IAzureResourceManagementSession session, ServerDefinition serverDefinition) { CommonUtil.CheckForNull(session, "session"); CommonUtil.CheckForNull(azureResourceManager, "azureResourceManager"); _session = session; AzureResourceManager = azureResourceManager; ServerDefinition = serverDefinition ?? ServerDefinition.Default; }