【问题标题】:Get-AzureStorageBlob : Could not get the storage context. Please pass in a storage context or set the current storage contextGet-AzureStorageBlob :无法获取存储上下文。请传入存储上下文或设置当前存储上下文
【发布时间】:2017-09-23 10:03:01
【问题描述】:

我正在使用带有 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.

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

为什么会出现这个错误?

是否使用了 AzureRM? AzureRM 版本列为 3.8.0。 我需要哪些版本的脚本才能让它工作?

【问题讨论】:

    标签: powershell azure blob azure-blob-storage


    【解决方案1】:

    您还需要在此处包含StorageContext

    $blobs = Get-AzureStorageBlob -Container  $Container
    

    所以你的代码是:

    $blobs = Get-AzureStorageBlob -Container $Container -Context $StorageContext
    

    【讨论】:

    • 作为一个“拱门”新手......我还需要了解更多信息,最后想通了: $StorageContext = New-AzureStorageContext -StorageAccountName "theaccountname" -StorageAccountKey = "Key1 or Key2"当然还有 -Context $StorageContext 放在上面的 cmdlet 中。
    • 可能是 New-AzureStorageContextNew-AzStorageContext,具体取决于 Azure Powershell 版本。
    猜你喜欢
    • 1970-01-01
    • 2015-04-23
    • 1970-01-01
    • 1970-01-01
    • 2012-12-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-13
    相关资源
    最近更新 更多