public CloudStorageAccount GetCurrentStorageAccount(IServiceManagement channel)
{
if (String.IsNullOrEmpty(CurrentStorageAccount))
{
return null;
}
if (this.CurrentCloudStorageAccount != null)
{
return CurrentCloudStorageAccount;
}
CloudStorageAccount currentStorage = null;
using (new OperationContextScope(channel.ToContextChannel()))
{
var storageService = channel.GetStorageService(SubscriptionId, CurrentStorageAccount);
var storageServiceKeys = channel.GetStorageKeys(SubscriptionId, 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);
}
}
this.CurrentCloudStorageAccount = currentStorage;
return currentStorage;
}