【问题标题】:Get Azure Storage Account Key inside Powershell Function App在 Powershell Function App 中获取 Azure 存储帐户密钥
【发布时间】:2020-11-05 08:02:44
【问题描述】:

我正在尝试从同一资源组“rg-mobileplans”下的 Powershell 功能应用程序中获取存储帐户的密钥。

我确定我拥有正确的 Azure 上下文,并且在列出所有存储帐户时,我看到了我试图从中检索密钥的那个 - “stmobileplansstaging”。

Write-Host ((Get-AzContext).Subscription)
Write-Host (Get-AzStorageAccount -ResourceGroupName rg-mobileplans).StorageAccountName

输出:

<Subscription ID Hidden for Privacy>
stmobileplansstaging storageaccountrgmob83d8

但是当我尝试获取密钥本身时,我收到一条错误消息,提示找不到存储帐户。

Get-AzStorageAccountKey -ResourceGroupName rg-mobileplans -AccountName stmobileplansstaging

输出:

ERROR: Get-AzStorageAccountKey : The Resource 'Microsoft.Storage/storageAccounts/stmobileplansstaging ' under resource group 'rg-mobileplans' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix

请记住,我是从函数应用程序运行这些命令。从 Powershell 运行它们是可行的。

我为函数应用创建了一个系统管理的身份,并授予它“所有者”访问整个“rg-mobileplans”资源组和“stmobileplansstaging”存储帐户的权限。

我错过了什么?

【问题讨论】:

    标签: azure powershell azure-function-app azure-storage-account


    【解决方案1】:

    我刚刚意识到问题所在。在脚本中,存储帐户名称通过标记给出。名字末尾有一个空格。运行 get / list storage account 命令时没问题并且命令成功,因为帐户的名称可能在末尾,但是为了获取密钥,正在发出 POST 调用,并且 URL 看起来像“http:/ /.../storage/stmobileplansstaging /rest-of-the-uri”。请注意 URI 中间的空格,它破坏了一切。

    【讨论】:

      猜你喜欢
      • 2017-05-01
      • 2017-08-19
      • 2021-05-12
      • 2021-11-15
      • 2019-09-17
      • 2019-01-14
      • 1970-01-01
      • 2023-03-23
      • 1970-01-01
      相关资源
      最近更新 更多