azure - MS Azure Blob 存储共享访问 token 适用于本地 IP,但在生成使用 VM IP 的另一个 token 时抛出 403(未经授权)

标签 azure azure-blob-storage unauthorized

我正在使用 Azure Portal 生成这些 token ,虽然它们似乎正在使用本地 IP 地址,但在使用带有 403 的虚拟机 IP 生成时失败。事实上,几个小时前它们似乎工作正常,但突然间尽管有 10 年的到期时间,但仍然开始失败。错误如下:

RequestId:c535ade9-701e-005a-20ad-25a762000000
Time:2023-01-11T11:12:48.4496393Z
 {
  "name": "RestError",
  "code": "AuthorizationFailure",
  "statusCode": 403,
  "request": {
    "streamResponseStatusCodes": {},
    "url": "https://ubstagingcontainer.blob.core.windows.net/ubstagingcontainer/ubstagingcontainer/contacts.png?sp=REDACTED&st=REDACTED&se=REDACTED&sip=REDACTED&spr=REDACTED&sv=REDACTED&sr=REDACTED&sig=REDACTED&comp=REDACTED&blockid=REDACTED",
    "method": "PUT",
    "headers": {
      "_headersMap": {
        "x-ms-version": "REDACTED",
        "content-length": "59935",
        "content-type": "application/octet-stream",
        "accept": "application/xml",
        "user-agent": "azsdk-js-storageblob/12.12.0 (NODE-VERSION v16.16.0; Linux 5.15.0-1029-azure)",
        "x-ms-client-request-id": "6242a2d8-b8bd-4d72-bd5b-7ca9dc0d0ad8",
        "cookie": "REDACTED"
      }
    },
    "withCredentials": false,
    "timeout": 0,
    "keepAlive": true,
    "decompressResponse": false,
    "requestId": "6242a2d8-b8bd-4d72-bd5b-7ca9dc0d0ad8"
  },
  "details": {
    "errorCode": "AuthorizationFailure",
    "content-length": "246",
    "content-type": "application/xml",
    "date": "Wed, 11 Jan 2023 11:12:48 GMT",
    "server": "Microsoft-HTTPAPI/2.0",
    "x-ms-client-request-id": "6242a2d8-b8bd-4d72-bd5b-7ca9dc0d0ad8",
    "x-ms-request-id": "c535ade9-701e-005a-20ad-25a762000000",
    "message": "This request is not authorized to perform this operation.\nRequestId:c535ade9-701e-005a-20ad-25a762000000\nTime:2023-01-11T11:12:48.4496393Z",
    "code": "AuthorizationFailure"
  },
  "message": "This request is not authorized to perform this operation.\nRequestId:c535ade9-701e-005a-20ad-25a762000000\nTime:2023-01-11T11:12:48.4496393Z"
}

最佳答案

如果您错过在存储帐户防火墙设置下添加虚拟机公共(public) IP 地址,则可能会出现错误“此请求无权执行此操作”

我尝试在我的环境中重现相同的结果并得到以下结果:

我有一个名为 sristorage12 的存储帐户,我在存储帐户防火墙设置中仅启用了对本地 IP 地址的访问,如下所示:

enter image description here

本地 IP 地址,我能够成功上传 blob,如下所示:

enter image description here

现在我尝试从虚拟机的 IP 地址执行相同的操作,但出现类似错误,如下所示:

enter image description here

当我向下滚动时,我收到相同的错误,提示“此请求无权执行此操作”如下所示:

enter image description here

解决该错误,请确保在存储帐户的防火墙设置下添加虚拟机的公共(public) IP 地址。

您可以从此处获取虚拟机的公共(public) IP 地址:

enter image description here

我在存储帐户的防火墙设置下添加了虚拟机的公共(public) IP 地址,如下所示:

enter image description here

现在,当我尝试从虚拟机的 IP 地址上传 Blob 时,Blob 已成功上传,没有任何错误,如下所示:

enter image description here

根据您的情况,请确保在存储帐户的防火墙设置下添加您的虚拟机的公共(public) IP 地址

如果错误仍然存​​在,请将存储帐户的网络设置更改为允许从所有网络进行访问,如下所示:

enter image description here

关于azure - MS Azure Blob 存储共享访问 token 适用于本地 IP,但在生成使用 VM IP 的另一个 token 时抛出 403(未经授权),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75082390/

相关文章:

google-cloud-storage - 以编程方式将文件从 Azure Blob 存储传输到 Google Cloud Storage

Azure Function 和 WindowsAzure.Storage 版本(DLL Hell)

azure - 发送到 Azure 服务总线主题的消息如何知道要转到哪个订阅?

Azure Blob 存储 - 同一文件夹中的文件数量是否有限制?

iis - msbuild-未经授权的AccessException : Retrieving the COM class factory for remote component with CLSID {2B72133B-3F5B-4602-8952-803546CE3344

c# - Confluence REST API 授权问题

ssl - CAC 卡登录未验证必须使用其 Windows 用户和密码的随机用户

azure - Azure 中的 JMeter DNS 间歇性故障

azure - 在 Azure Devops 上的 cURL 请求中使用环境变量

azure - 不确定该容器是否在 azure storage 中列为 []