21
21
using Microsoft . Azure . Management . Compute . Models ;
22
22
using Microsoft . WindowsAzure . Commands . Common . Storage ;
23
23
using Microsoft . WindowsAzure . Commands . Utilities . Common ;
24
- using Microsoft . WindowsAzure . Management . Storage ;
24
+ using Microsoft . Azure . Commands . Management . Storage ;
25
+ using Microsoft . Azure . Management . Storage ;
25
26
using Newtonsoft . Json ;
26
27
27
28
namespace Microsoft . Azure . Commands . Compute
@@ -37,7 +38,7 @@ public class SetAzureVMDiagnosticsExtensionCommand : VirtualMachineExtensionBase
37
38
private const string VirtualMachineExtension = "Microsoft.Compute/virtualMachines/extensions" ;
38
39
private const string IaaSDiagnosticsExtension = "IaaSDiagnostics" ;
39
40
private const string ExtensionPublisher = "Microsoft.Azure.Diagnostics" ;
40
- private StorageManagementClient storageClient ;
41
+ private IStorageManagementClient storageClient ;
41
42
42
43
[ Parameter (
43
44
Mandatory = true ,
@@ -154,14 +155,14 @@ public string PrivateConfiguration
154
155
}
155
156
}
156
157
157
- public StorageManagementClient StorageClient
158
+ public IStorageManagementClient StorageClient
158
159
{
159
160
get
160
161
{
161
162
if ( this . storageClient == null )
162
163
{
163
164
this . storageClient = AzureSession . ClientFactory . CreateClient < StorageManagementClient > (
164
- DefaultProfile . Context , AzureEnvironment . Endpoint . ServiceManagement ) ;
165
+ DefaultProfile . Context , AzureEnvironment . Endpoint . ResourceManager ) ;
165
166
}
166
167
167
168
return this . storageClient ;
@@ -201,15 +202,8 @@ protected string GetStorageKey()
201
202
202
203
if ( ! string . IsNullOrEmpty ( StorageAccountName ) )
203
204
{
204
- var storageAccount = this . StorageClient . StorageAccounts . Get ( StorageAccountName ) ;
205
- if ( storageAccount != null )
206
- {
207
- var keys = this . StorageClient . StorageAccounts . GetKeys ( StorageAccountName ) ;
208
- if ( keys != null )
209
- {
210
- storageKey = ! string . IsNullOrEmpty ( keys . PrimaryKey ) ? keys . PrimaryKey : keys . SecondaryKey ;
211
- }
212
- }
205
+ var storageCredentials = StorageUtilities . GenerateStorageCredentials ( this . StorageClient , this . ResourceGroupName , this . StorageAccountName ) ;
206
+ storageKey = storageCredentials . ExportBase64EncodedKey ( ) ;
213
207
}
214
208
215
209
return storageKey ;
0 commit comments