Azure blob下载授权资源类型不匹配



我正试图从他们的azure存储中下载JSON格式的客户端blob数据。

我有包含SAS令牌的帐户URL、SAS令牌本身以及连接URL。

然而,当我试图从他们的服务器下载blob时,我得到了以下错误:

This request is not authorized to perform this operation using this resource type.
RequestId:d6d9d23e-301e-0078-32be-ecd22a000000
Time:2020-02-26T16:02:05.6188260Z
ErrorCode:AuthorizationResourceTypeMismatch
Error:None

这是我正在使用的代码:

import os, uuid
from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient
try:
account_url = "account_url/sas_token"
# Open the container containing the relevant blobs
container = ContainerClient(account_url, container_name="container_name")
# Printing the available blobs 
blob_list = container.list_blobs()
for blob in blob_list:
print(blob.name + 'n')
blob_client=container.get_blob_client("blob_name")
print(blob_client)
with open("./test.txt", "wb") as my_blob:
blob_data = blob_client.download_blob()
blob_data.readinto(my_blob)

except Exception as ex:
print('Exception:')
print(ex)

如有关于此错误的更多信息,我们将不胜感激!感谢:D

由于您的目标是下载blob,请确保您的signed resource type (srt)应包括object (o)

你的srt应该和srt=co一样(或者只是srt=o(。

请相应地重新生成SAS令牌。

您可以在此处通过操作查看帐户SAS权限:https://learn.microsoft.com/en-us/rest/api/storageservices/create-account-sas#account-sas权限按操作(下载Blob基本上就是获取Blob操作(。

最新更新