/// <summary> /// Returns the databases for given connection info. /// The connection info should be used to make the connection for getting databases not the account manager /// </summary> //public async Task<ServiceResponse<DatabaseInstanceInfo>> GetDatabaseInstancesAsync(UIConnectionInfo uiConnectionInfo, CancellationToken cancellationToken) //{ // ServiceResponse<DatabaseInstanceInfo> result = null; // if (DefaultDatabaseDiscoveryProvider != null && DefaultDatabaseDiscoveryProvider != this) // { // result = await DefaultDatabaseDiscoveryProvider.GetDatabaseInstancesAsync(uiConnectionInfo, cancellationToken); // } // else // { // result = new ServiceResponse<DatabaseInstanceInfo>(); //TODO: add error that we couldn't find any default database provider // } // return result; //} /// <summary> /// Returns the databases for given server name. Using the account manager to get the databases /// </summary> public async Task <ServiceResponse <DatabaseInstanceInfo> > GetDatabaseInstancesAsync(string serverName, CancellationToken cancellationToken) { ServiceResponse <DatabaseInstanceInfo> result = null; if (AzureResourceManager != null && AccountManager != null && AzureAccountManager != null) { try { //if connection is passed, we need to search all subscriptions not selected ones IEnumerable <IAzureUserAccountSubscriptionContext> subscriptions = await GetSubscriptionsAsync(string.IsNullOrEmpty(serverName)); if (!cancellationToken.IsCancellationRequested) { result = await AzureUtil.ExecuteGetAzureResourceAsParallel((object)null, subscriptions, serverName, cancellationToken, GetDatabaseForSubscriptionAsync); } } catch (Exception ex) { result = new ServiceResponse <DatabaseInstanceInfo>(ex); } } result = result ?? new ServiceResponse <DatabaseInstanceInfo>(); return(result); }
public async Task <ServiceResponse <DatabaseInstanceInfo> > GetDatabasesForServers(IList <IAzureSqlServerResource> serverResources, CancellationToken cancellationToken) { ServiceResponse <DatabaseInstanceInfo> result = new ServiceResponse <DatabaseInstanceInfo>(); if (serverResources != null) { result = await AzureUtil.ExecuteGetAzureResourceAsParallel(_session, serverResources, null, cancellationToken, GetDatabasesForServerFromService); } return(result); }