为什么我在Azure存储帐户中没有主键

时间:2016-09-27 00:34:04

标签: powershell azure azure-storage-blobs

我在powershell中有这段代码:

$storageAccount = 'newstorage200'
$resourceGroup = 'Group'
$storeKey = (Get-AzureRmStorageAccountKey -ResourceGroupName $resourceGroup -StorageAccountName $storageAccount).Primary

存储在$ storeKey变量中的值为空。为什么我没有主键?

2 个答案:

答案 0 :(得分:4)

在此处参考cmdlet文档:https://msdn.microsoft.com/en-us/library/mt607145.aspx,您应该这样称呼它。

$storageAccount = 'newstorage200'
$resourceGroup = 'Group'
$storeKey = ((Get-AzureRmStorageAccountKey -ResourceGroupName $resourceGroup -Name $storageAccount)| Where-Object {$_.KeyName -eq 'key1'}).Value

答案 1 :(得分:0)

当我这样打电话时,它成功了:

$storageAccount = 'newacc2001'
$resourceGroup = 'Group'
$storeKey = Get-AzureRmStorageAccountKey -ResourceGroupName $resourceGroup -StorageAccountName $storageAccount
$storeContext = New-AzureStorageContext -StorageAccountName $storageAccount -StorageAccountKey $storeKey[0].Value