Skip to content

Commit

Permalink
Merge pull request #1112 from rahulpandit85/dev
Browse files Browse the repository at this point in the history
Use V2 Storage accounts for RM based Diagnostics Extenstion
  • Loading branch information
ogail committed Oct 20, 2015
2 parents 93edfa5 + 5c679fd commit 8d44f81
Showing 1 changed file with 7 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
using Microsoft.Azure.Management.Compute.Models;
using Microsoft.WindowsAzure.Commands.Common.Storage;
using Microsoft.WindowsAzure.Commands.Utilities.Common;
using Microsoft.WindowsAzure.Management.Storage;
using Microsoft.Azure.Commands.Management.Storage;
using Microsoft.Azure.Management.Storage;
using Newtonsoft.Json;

namespace Microsoft.Azure.Commands.Compute
Expand All @@ -37,7 +38,7 @@ public class SetAzureVMDiagnosticsExtensionCommand : VirtualMachineExtensionBase
private const string VirtualMachineExtension = "Microsoft.Compute/virtualMachines/extensions";
private const string IaaSDiagnosticsExtension = "IaaSDiagnostics";
private const string ExtensionPublisher = "Microsoft.Azure.Diagnostics";
private StorageManagementClient storageClient;
private IStorageManagementClient storageClient;

[Parameter(
Mandatory = true,
Expand Down Expand Up @@ -154,14 +155,14 @@ public string PrivateConfiguration
}
}

public StorageManagementClient StorageClient
public IStorageManagementClient StorageClient
{
get
{
if (this.storageClient == null)
{
this.storageClient = AzureSession.ClientFactory.CreateClient<StorageManagementClient>(
DefaultProfile.Context, AzureEnvironment.Endpoint.ServiceManagement);
DefaultProfile.Context, AzureEnvironment.Endpoint.ResourceManager);
}

return this.storageClient;
Expand Down Expand Up @@ -201,15 +202,8 @@ protected string GetStorageKey()

if (!string.IsNullOrEmpty(StorageAccountName))
{
var storageAccount = this.StorageClient.StorageAccounts.Get(StorageAccountName);
if (storageAccount != null)
{
var keys = this.StorageClient.StorageAccounts.GetKeys(StorageAccountName);
if (keys != null)
{
storageKey = !string.IsNullOrEmpty(keys.PrimaryKey) ? keys.PrimaryKey : keys.SecondaryKey;
}
}
var storageCredentials = StorageUtilities.GenerateStorageCredentials(this.StorageClient, this.ResourceGroupName, this.StorageAccountName);
storageKey = storageCredentials.ExportBase64EncodedKey();
}

return storageKey;
Expand Down

0 comments on commit 8d44f81

Please sign in to comment.