public static CloudStorageAccount GetCurrentCloudStorageAccount(IServiceManagement channel, SubscriptionData subscriptionData)
{
if (String.IsNullOrEmpty(subscriptionData.CurrentStorageAccount))
{
return null;
}
if (subscriptionData.CurrentCloudStorageAccount != null)
{
return subscriptionData.CurrentCloudStorageAccount;
}
CloudStorageAccount currentStorage = null;
using (new OperationContextScope(channel.ToContextChannel()))
{
var storageService = channel.GetStorageService(subscriptionData.SubscriptionId, subscriptionData.CurrentStorageAccount);
var storageServiceKeys = channel.GetStorageKeys(subscriptionData.SubscriptionId, subscriptionData.CurrentStorageAccount);
if (storageService != null && storageServiceKeys != null)
{
string connectionString = General.BuildConnectionString("https", storageService.ServiceName, storageServiceKeys.StorageServiceKeys.Primary, storageService.StorageServiceProperties.Endpoints[0].Replace("http://", "https://"), storageService.StorageServiceProperties.Endpoints[2].Replace("http://", "https://"), storageService.StorageServiceProperties.Endpoints[1].Replace("http://", "https://"));
currentStorage = CloudStorageAccount.Parse(connectionString);
}
}
subscriptionData.CurrentCloudStorageAccount = currentStorage;
return currentStorage;
}