我正在尝试通过访问azure上存储帐户中blob容器中的blob文件azure.blob.存储python文件。存在公共访问级别设置为“private”、“blob”和“container”的blob容器
我已通过具有所有权限的azure门户为存储帐户创建了SAS令牌。通过python代码,我可以访问blob容器中具有“container”访问级别的文件。但是,我无法访问具有“blob”和“private”级别的容器
from datetime import datetime, timedelta
def test_check_blob_containers():
account_name = ''
account_key = ''
container_name = ''
#sas_token = get_sas_token(account_name, account_key, container_name)
# I have used the sas token generated through get_sas_token as well as the one retrieved from the azure portal which was created manually.
sas_token = 'sas token retrieved from the azure portal'
block_blob_service = BlockBlobService(
account_name=account_name, sas_token=quote(sas_token))
blobs = block_blob_service.list_blobs(container_name=container_name)
for b in blobs:
print(b.name)
def get_sas_token(account_name, account_key, container_name):
blob_service = BlockBlobService(account_name=account_name, account_key=account_key)
sas_token = blob_service.generate_container_shared_access_signature(container_name, ContainerPermissions.LIST, datetime.utcnow() + timedelta(hours=1))
return sas_token
我得到以下错误:
提高ex
azure.common.AzureMissingResourceHttpError错误:指定的资源不存在
不存在。错误代码:ResourceNotFound
EResourceNotFound
指定的资源不存在。
电子请求ID:ea63a1df-001e-0003-6ffd-719913000000
电子时间:2019-09-23T10:56:42.8358696赫兹
我可以复制你的问题在我这边,这个问题是由
quote()
引起的,删除它就行了。你知道吗这条线应该如下所示。你知道吗
相关问题 更多 >
编程相关推荐