public static CloudStorageAccount GetCloudStorageAccount(this WindowsAzureSubscription subscription) { if (subscription == null || subscription.SubscriptionId == null) { return(null); } if (subscription.currentCloudStorageAccount != null) { return(subscription.currentCloudStorageAccount as CloudStorageAccount); } else { using (var storageClient = subscription.CreateClient <StorageManagementClient>()) { var storageServiceResponse = storageClient.StorageAccounts.Get(subscription.currentStorageAccountName); var storageKeysResponse = storageClient.StorageAccounts.GetKeys(subscription.currentStorageAccountName); subscription.currentCloudStorageAccount = new CloudStorageAccount( new StorageCredentials(storageServiceResponse.StorageAccount.Name, storageKeysResponse.PrimaryKey), GeneralUtilities.CreateHttpsEndpoint(storageServiceResponse.StorageAccount.Properties.Endpoints[0].ToString()), GeneralUtilities.CreateHttpsEndpoint(storageServiceResponse.StorageAccount.Properties.Endpoints[1].ToString()), GeneralUtilities.CreateHttpsEndpoint(storageServiceResponse.StorageAccount.Properties.Endpoints[2].ToString())); return(subscription.currentCloudStorageAccount as CloudStorageAccount); } } }
public static CloudStorageAccount GetCloudStorageAccount(this WindowsAzureSubscription subscription) { if (subscription == null || subscription.SubscriptionId == null) { return(null); } if (subscription.currentCloudStorageAccount != null) { return(subscription.currentCloudStorageAccount as CloudStorageAccount); } else { using (var storageClient = subscription.CreateClient <StorageManagementClient>()) { subscription.currentCloudStorageAccount = StorageUtilities.GenerateCloudStorageAccount( storageClient, subscription.currentStorageAccountName); return(subscription.currentCloudStorageAccount as CloudStorageAccount); } } }