【问题标题】:Connect to azure blob storage连接到 Azure Blob 存储
【发布时间】:2022-08-03 14:47:54
【问题描述】:

我正在使用以下 powershell 脚本使用我的开发凭据连接到 azure datalake storage gen2,部署后使用托管身份凭据。

代码:

try {
        $AzStorageContext = (Connect-AzAccount -Identity).context;
    }
catch{
        $AzStorageContext = (Connect-AzAccount).context;
    }

$AzStorageContext = Set-AzContext -SubscriptionName $AzStorageContext.Subscription -DefaultProfile $AzStorageContext
Get-AzStorageContainer -Name \'MyContainer\' -Context $AzStorageContext

我遇到的错误是

错误:

Get-AzStorageContainer : Cannot bind parameter \'Context\'. Cannot convert the \"Microsoft.Azure.Commands.Profile.Models.Core.PSAzureContext\" value of type 
\"Microsoft.Azure.Commands.Profile.Models.Core.PSAzureContext\" to type \"Microsoft.Azure.Commands.Common.Authentication.Abstractions.IStorageContext\".

    标签: powershell azure-data-lake-gen2


    【解决方案1】:

    使用 Powershell 将 Azure 存储与系统分配的托管标识连接起来

    $AzureContext = (Connect-AzAccount -Identity).context
    
    $AzureContext = Set-AzContext -SubscriptionName $AzureContext.Subscription -DefaultProfile $AzureContext
    

    有关更多信息,请参阅 VenkateshDodda-MSFT 的 SO 线程

    【讨论】:

      猜你喜欢
      • 2021-07-11
      • 2017-09-17
      • 1970-01-01
      • 2022-12-11
      • 2016-02-18
      • 1970-01-01
      • 1970-01-01
      • 2020-05-28
      • 1970-01-01
      相关资源
      最近更新 更多