我在powershell中有这段代码:
$storageAccount = 'newstorage200'
$resourceGroup = 'Group'
$storeKey = (Get-AzureRmStorageAccountKey -ResourceGroupName $resourceGroup -StorageAccountName $storageAccount).Primary
存储在$ storeKey变量中的值为空。为什么我没有主键?
答案 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