繁体   English   中英

Azure Blob - 403 上传 - Sitecore CM/CD 拓扑

[英]Azure Blob - 403 on upload - Sitecore CM / CD topology

我正在尝试使用 Azure.Storage.Blob 库将来自 Sitecore 网站的图像上传到 Azure Blob 存储中。 在单个拓扑中,在我们的测试环境中,它可以毫无问题地工作,即使在我们的本地设置上也是如此。 另一方面,在我们的暂存环境(具有 CM/CD 拓扑)中,它会抛出 403 状态。

存储帐户是公共的,我们可以从本地机器/测试环境对该存储帐户进行任何操作。 此外,对于暂存环境,我们确实在 Azure 中设置了一个前门,但即使禁用它,仍然抛出相同的异常。

有没有人遇到过这个问题? 调查了几天,但我变得一无所知。 谢谢你。

例外情况如下:


Exception: Azure.RequestFailedException
Message: Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
RequestId:8e1769d5-e01e-001e-0499-ac8ce4000000
Time:2022-08-10T09:13:32.0353745Z
Status: 403 (Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.)
ErrorCode: AuthenticationFailed

Additional Information:
AuthenticationErrorDetail: The MAC signature found in the HTTP request 'cJB+JGEEjhxJiYsAlcnlZOBw09rreVlAd5eJMis7vD0=' is not the same as any computed signature. Server used following string to sign: 'PUT

887486

application/octet-stream

x-ms-blob-type:BlockBlob
x-ms-client-request-id:5a970fad-c322-41dd-9c79-be7b52057fdd
x-ms-date:Wed, 10 Aug 2022 09:13:32 GMT
x-ms-request-id:|NoBMxLCuSY4=.5431b150_8.
x-ms-request-root-id:NoBMxLCuSY4=
x-ms-return-client-request-id:true
x-ms-version:2021-04-10
/[sa_name]/[container_name]/AdvertisementMedia/10c8df42-8803-4acb-38eb-08da7a1ea032/5viawtti.zki.png'```

当 MAC 签名格式不正确或使用不正确的密钥签名时,通常会发生此错误。 如果您直接使用 Azure.Storage.Blob 库,Sitecore 应用程序的 CM/CD 拓扑无关紧要。

但是,如果相同的代码和配置在其他环境中运行正常,请尝试比较 HTTP 标头以识别本地环境和暂存环境之间的差异。 以下是我过去看到的几个常见原因:

  1. x-ms-date header 包含不正确的日期或日期不正确的时区。 日期应为当前 UTC 日期时间且不超过 15 分钟,否则 Azure 存储服务将返回响应代码403 (Forbidden) 如果您的登台服务器使用与 UTC 不同的时区,则可能是问题所在。
  2. MAC 签名中不包含一个额外的 header。 例如,我可以在您的异常中看到 header x-ms-request-root-id ,Application Insights 会自动将其添加到传出请求中。 如果在暂存环境中具有启用依赖项跟踪的 Application Insights,请确保在ApplicationInsights.config中为域core.windows.net禁用其他 HTTP 标头:
<TelemetryModules>
   <Add Type="Microsoft.ApplicationInsights.DependencyCollector.DependencyTrackingTelemetryModule, Microsoft.AI.DependencyCollector"> 
      <ExcludeComponentCorrelationHttpHeadersOnDomains>
         <Add>core.windows.net</Add> 
      </ExcludeComponentCorrelationHttpHeadersOnDomains>
   </Add>
</TelemetryModules>

您可以在此处阅读有关签名字符串的更多信息。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM