Get-AzureStorageBlob:无法获取存储上下文.请传入存储上下文或设置当前存储上下文

Pet*_*ock 7 powershell blob azure azure-storage-blobs

我在Azure cmdlet中使用PowerShell来尝试简单地查看blob存储中的项目

  $StorageContext = New-AzureStorageContext -StorageAccountName 'myblobname' -StorageAccountKey '2341231234asdff2352354345=='
  $Container = Get-AzureStorageContainer -Name 'mycontainer' -Context $StorageContext  
  $blobs = Get-AzureStorageBlob -Container  $Container

Error:
Get-AzureStorageBlob : Could not get the storage context.  Please pass in a storage context or set the current storage context.
Run Code Online (Sandbox Code Playgroud)

我100%确定凭据是正确的(这篇文章中只是随机缩短的凭证数据)

为什么我会收到此错误?

AzureRM使用了吗?AzureRM版本列为3.8.0.我需要哪些版本的脚本才能工作?

Gau*_*tri 6

你还需要在StorageContext这里包括:

$blobs = Get-AzureStorageBlob -Container  $Container
Run Code Online (Sandbox Code Playgroud)

所以你的代码是:

$blobs = Get-AzureStorageBlob -Container $Container -Context $StorageContext
Run Code Online (Sandbox Code Playgroud)

  • 作为一个"拱"新手...我还需要了解更多,最后想出来:$ StorageContext = New-AzureStorageContext -StorageAccountName"theaccountname"-StorageAccountKey ="Key1 or Key2"当然-Context $ StorageContext放在上面的cmdlet中. (3认同)