SAS访问Blob容器(azure / python)

问题描述 投票:1回答:1

我想在不共享我的整个存储帐户密钥的情况下,限制对我帐户中单个容器的访问。我在特定于容器的Azure Storage Explorer中生成了共享访问签名。

container right-click & generate SAS

example of output from generate SAS

[当我尝试使用blockblobservice列出文件时,出现以下错误。使用get_blob_to_path时出现相同的错误。

from azure.storage.blob import BlockBlobService, BlobPermissions

sas_container = 'nwe-statements'
sas_token = '?st=2019-12-05T21%3A09%3A12Z&se=2020-01-31T21%3A13%3A00Z&sp=racwdl&sv=2018-03-28&sr=c&sig=YLk2UWxPcqkDl5a8nWtBYcw%3DxWuAsfFI1ch5TwrbAxvk'
example_file = '1470-4126.pdf'

def sas_list():
    blob_service = BlockBlobService(account_name='pretend',sas_token=sas_token)
    blob_list = blob_service.list_blobs(sas_container)
    print(blob_list)

追踪(最近通话):在第24行的“ /home/brett/jetco/django_jetco/O365/nwe_statements/blob_connect.py”文件中sas_list()sas_list中第11行的文件“ /home/brett/jetco/django_jetco/O365/nwe_statements/blob_connect.py”blob_list = blob_service.list_blobs(sas_container)在list_blobs中的文件“ /home/brett/jetco/env/lib/python3.6/site-packages/azure/storage/blob/baseblobservice.py”,第1214行resp = self._list_blobs(* args,** kwargs)_list_blobs中的文件“ /home/brett/jetco/env/lib/python3.6/site-packages/azure/storage/blob/baseblobservice.py”,行1285返回self._perform_request(请求,_convert_xml_to_blob_list,operation_context = _context)_perform_request中的第280行的文件“ /home/brett/jetco/env/lib/python3.6/site-packages/azure/storage/storageclient.py”提高前_perform_request中的文件“ /home/brett/jetco/env/lib/python3.6/site-packages/azure/storage/storageclient.py”,第248行提高前_perform_request中的文件“ /home/brett/jetco/env/lib/python3.6/site-packages/azure/storage/storageclient.py”,第235行_http_error_handler(HTTPError(response.status,response.message,response.headers,response.body))_http_error_handler中的文件“ /home/brett/jetco/env/lib/python3.6/site-packages/azure/storage/_error.py”,第114行引发AzureHttpError(消息,http_error.status)azure.common.AzureHttpError:服务器无法验证请求。确保包括签名在内的Authorization标头的值正确形成。AuthenticationFailed服务器无法验证请求。确保包括签名在内的Authorization标头的值正确形成。RequestId:2d2370dc-f01e-0028-0fb3-ab47c9000000时间:2019-12-05T21:33:23.3062345Z签名不匹配。用于签名的字符串是racwdl

2020-01-31T21:13:00Z/ blob / pretend / nwe-statements

2018-03-28

python azure-storage-blobs
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.