繁体   English   中英

基于元数据列出 azure blob - python sdk

[英]list azure blobs based on metadata - python sdk

我正在使用 azure blob 存储 sdk,我希望有办法根据某些元数据信息过滤 blob。

from azure.storage.blob import BlobServiceClient

container_name = 'c1'
blob_service_client = BlobServiceClient.from_connection_string(os.environ['STORAGE_ACCOUNT_CONNECTION_STRING'])
container_client = blob_service_client.get_container_client(container_name)

all_blobs = container_client.list_blobs(include='metadata')

for in in all_blobs:
    print('{}'.format(i.name))

我在该帐户中保存了数千个 blob,并且希望在我的应用中加快搜索速度 - 有没有办法根据元数据进行过滤? 我不想查询所有 blob 并进行列表理解。 - 谢谢!

您的包含必须是 BlobProperties 列表:

service_client = BlobServiceClient.from_connection_string(connection_string)
container_client = service_client.get_container_client(container_name)

blob_iter = service_client.list_blobs(name_starts_with=None, include=["metadata"])
for i in blob_iter:
    print(i)

参考: https : //docs.microsoft.com/de-de/python/api/azure-storage-blob/azure.storage.blob.blobproperties?view=azure-pythonhttps://docs.microsoft.com /de-de/python/api/azure-storage-blob/azure.storage.blob.containerclient?view=azure-python#list-blobs-name-starts-with-none--include-none----kwargs ——

暂无
暂无

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

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