python - 使用 python 生成的 sas 令牌不适用于 azure blob
问题描述
我必须使用 python 在函数应用程序中为 blob 生成 SAS 令牌。我使用了以下代码。
sas_url=generate_blob_sas(account_name=AZURE_ACC_NAME, container_name=AZURE_CONTAINER, blob_name=AZURE_BLOB, snapshot=None, account_key=AZURE_PRIMARY_KEY, user_delegation_key=None, permission="racwd", expiry='2021-06-08', start="2021-06-07", policy_id=None, ip=None)
# used following pattern to generate url
url='https://'+AZURE_ACC_NAME+'.blob.core.windows.net/'+AZURE_CONTAINER+'/'+AZURE_BLOB+'?'+sas_url
生成的 sas 令牌有 st,se,sp,sv,sr 和 sig
它给了我错误
<Error>
<Code>AuthenticationFailed</Code>
<Message>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. RequestId:f8bf0c5e-xxxx-xxxx-xxxx-xxxxxxxxxxxx Time:2021-06-08T06:27:02.0864172Z</Message>
<AuthenticationErrorDetail>Signature not valid in the specified time frame: Start [Mon, 07 Jun 2021 00:00:00 GMT] - Expiry [Tue, 08 Jun 2021 00:00:00 GMT] - Current [Tue, 08 Jun 2021 06:27:02 GMT]</AuthenticationErrorDetail>
</Error>
要求是我不能将 blob 设为公开,并且 url 应该在某个时间过期。
解决方案
此问题与您设置为的 SAS 到期日期有关2021-06-08
。这意味着您的 SAS 令牌将在 2021 年 6 月 8 日午夜(UTC)到期。
请将其更改为将来的日期(例如2021-06-09
),您的 SAS 令牌应该可以正常工作。
推荐阅读
- xamarin - Xamarin 应用程序可以在 BrowserStack 上使用 App Live Local Testing
- wordpress - Woocommerce:检查购物车是否包含任何产品的功能
- python - Python else 语句的问题
- sql - 有年份的月份列表
- mongodb - 猫鼬:在对象内查找值,在对象数组内的数组内查找
- r - R:预测新数据集的值
- python - 打卡代码单独适用于员工功能和主管功能,但在组合时无效
- c# - HTML Razor 中 Step 属性的自定义错误验证
- oracle - 运行 DBMS 计划作业时,我是哪个 Windows 用户?
- c++ - 如何删除排序向量中的重复项