gpt4 book ai didi

azure - 状态 = 403 代码 ="AuthorizationFailure"消息 ="This request is not authorized to perform this operation"

转载 作者:行者123 更新时间:2023-12-02 05:52:22 28 4
gpt4 key购买 nike

我正在尝试运行一个部署存储容器的 terraform 部署。初始部署有效(由于尚未到位 IP 过滤),但随后失败。运行 terraform plan 时,我得到以下信息:

Error: retrieving Container "xxxx" (Account "xxxx" / Resource Group "xxx"): containers.Client#GetProperties: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: Service returned an error. Status=403 Code="AuthorizationFailure" Message="This request is not authorized to perform this operation.\nRequestId:62a85c92-901e-0021-12de-816608000000\nTime:2022-06-17T00:11:56.2063816Z"

根据一些研究和调试,当存储容器没有将托管管道代理的 IP 列入白名单时,就会发生这种情况。

我已经修改了管道,以便检索代理的 IP 并将其添加为防火墙规则。然后我添加了不同时间的 sleep (最多 5 分钟)来尝试给规则生效的时间,但它从来没有起作用。

这是我的管道的片段:

          - task: AzureCLI@2
inputs:
azureSubscription: '$(azureSubscription)'
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: |
agentIP=$(curl -s https://api.ipify.org/)
az storage account network-rule add -g xxx --account-name xxx --ip-address $agentIP
sleep 300

在 sleep 期间我已确认代理IP已添加到白名单中。白名单也是在与 terraform 计划相同的阶段完成的。

有人可以建议我哪里可能出错吗?

编辑

我更进一步,在管道中添加了一个步骤,将 DevOps 组织区域(114 个范围)中的所有 IP 地址列入白名单,但它仍然失败。

我的 Azure DevOps 管道代理获取的 IP 甚至不属于 az network list-service-tags --location australiaeast --query "values[?name == 'AzureCloud.australiaeast'].properties.addressPrefixes[]" 返回的范围的一部分

最佳答案

要解决错误“Status=403 Code=AuthorizationFailure Message=此请求无权执行此操作”,请尝试修改 Azure 门户中的设置,如下所示:

转至 Azure 门户 -> 存储帐户 -> 您从 terraform 创建的存储帐户 -> 网络

enter image description here

  • 启用“允许受信任的 Microsoft 服务访问此存储帐户”可让您访问存储帐户。
  • 确保拥有所需的权限,例如贡献者用户访问管理员角色/存储 Blob 数据所有者角色。

如果问题仍然存在,请使用类似 SO Thread 中的示例代码作者:安苏曼·巴尔

关于azure - 状态 = 403 代码 ="AuthorizationFailure"消息 ="This request is not authorized to perform this operation",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72653133/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com