Skip to content

Commit 5c679fd

Browse files
committed
Use StorageUtilities to fetch Storage Account keys
1 parent 13d9dda commit 5c679fd

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/ResourceManager/Compute/Commands.Compute/Extension/Diagnostics/SetAzureVMDiagnosticsExtension.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,8 @@ protected string GetStorageKey()
202202

203203
if (!string.IsNullOrEmpty(StorageAccountName))
204204
{
205-
var storageAccountKeys =
206-
this.StorageClient.StorageAccounts.ListKeys(this.ResourceGroupName,
207-
this.StorageContext.StorageAccountName);
208-
if (storageAccountKeys != null)
209-
{
210-
storageKey = !string.IsNullOrEmpty(storageAccountKeys.StorageAccountKeys.Key1) ? storageAccountKeys.StorageAccountKeys.Key1 : storageAccountKeys.StorageAccountKeys.Key2;
211-
}
205+
var storageCredentials = StorageUtilities.GenerateStorageCredentials(this.StorageClient, this.ResourceGroupName, this.StorageAccountName);
206+
storageKey = storageCredentials.ExportBase64EncodedKey();
212207
}
213208

214209
return storageKey;

0 commit comments

Comments
 (0)