2016-12-05 47 views
0

以下代码直到昨天才正常工作,但今天它正在给我一个如下所述的错误。将StorageAccount密钥传递到新的上下文时出错

$StorageAccountName = "xyz" 
$StorageAccountKey = Get-AzureRmStorageAccountKey -StorageAccountName $StorageAccountName 
$Ctx = New-AzureStorageContext $StorageAccountName -StorageAccountKey $StorageAccountKey.Primary 

试图与

$Ctx = New-AzureStorageContext $StorageAccountName -StorageAccountKey $StorageAccountKey.key1 

这里替换上面代码的最后一行的错误:

New-AzureStorageContext : Cannot validate argument on parameter 'StorageAccountKey'. The argument is null or empty. 
Provide an argument that is not null or empty, and then try the command again. 

回答

1
$Ctx = New-AzureStorageContext $StorageAccountName -StorageAccountKey 
$StorageAccountKey.value[0] 

您可以轻松地自己找出答案与$StorageAccount | Get-Member

+0

这已经工作,但缺乏riosity想知道使用'$ StorageAccountKey.Primary'或'$ StorageAccountKey.key1' –

+1

这个问题,我已经给你解释了。 '$ StorageAccountKey'对象不再具有这些属性,您可以检查自己,执行'| gm'然后看。 – 4c74356b41