【问题标题】:Azure App Service rejected with 403 error by Storage AccountAzure App Service 被存储帐户拒绝并出现 403 错误
【发布时间】:2021-07-29 17:09:28
【问题描述】:

我们的应用服务器被存储帐户拒绝。

我们生成了正确的 SAS 令牌,我们可以在本地访问容器。 (码头工人,intelliJ,邮递员)

  • WebbApp 和存储帐户位于同一位置(德国中西部 UTC+2)。
  • 我们有标准的订阅/计划
  • 我们将容器设置为公开。
  • 我们将 IP 地址设置为防火墙。
  • 我们使用 azure sdk java

我们尝试调用 Blob 服务。

当应用在 Azure 服务器上运行时,我们收到一条错误消息。

com.azure.storage.blob.models.BlobStorageException at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance

If you are using a SAS token, and the server returned an error message that says 'Signature did not match', you can compare the string to sign with the one generated by the SDK. To log the string to sign, pass in the context key value pair 'Azure-Storage-Log-String-To-Sign': true to the appropriate generateSas method call.
Please remember to disable 'Azure-Storage-Log-String-To-Sign' before going to production as this string can potentially contain PII.
Status code 403, "<?xml version="1.0" encoding="utf-8"?><Error><Code>AuthorizationFailure</Code><Message>This request is not authorized to perform this operation.
RequestId:959d813f-601e-0057-262f-4351a4000000
Time:2021-05-07T10:53:45.0157340Z</Message></Error>"

更新

我们将时区设置为 UTC-0。 它解决了我们的问题。服务在 UTC-0 时区运行。

【问题讨论】:

  • 这个错误很可能是由于防火墙规则而出现的。因此,不允许您的 WebApp 访问您的存储帐户。
  • 我在存储帐户中添加了我的防火墙设置的图片。
  • 哦,所以你没有定义任何防火墙规则。只是为了确认一下,您可以使用本地的 SAS URL 访问相同的存储帐户吗?可以分享一下 SAS 网址吗?只需混淆您的 SAS URL 的帐户名称、容器名称和 sig 部分。
  • 您的 SAS 令牌看起来不错。你能回答我的其他问题吗?
  • 我可以知道您的应用服务如何获取此 SAS 令牌吗?

标签: azure azure-functions azure-web-app-service azure-storage-account


【解决方案1】:

我们将时区设置为 UTC-0。它解决了我们的问题。服务在 UTC-0 时区运行。

【讨论】:

    【解决方案2】:

    您应该检查两件事:

    1. 如何获得此 SAS 令牌。
    2. 您是否在本地和远程之间使用了不同的容器。

    如您所说,您可以在本地成功使用它,然后您可以尝试调试您的代码以获取 sas uri 值,并通过浏览器直接访问它。

    最后,如果没有帮助,您可以尝试generate the SAS token from portal,并将 sas 令牌硬编码到您的代码中。

    【讨论】:

    • 我们在 Azure 网站上生成 SAS 令牌。
    猜你喜欢
    • 2020-04-05
    • 2020-05-09
    • 2020-06-04
    • 2020-10-06
    • 2020-01-25
    • 1970-01-01
    • 2019-05-30
    • 2016-04-21
    • 2018-12-28
    相关资源
    最近更新 更多