[英]list azure blobs based on metadata - python sdk
I'm using the azure blob storage sdk and I hoped that there would be way to filter blobs based on certain metadata information.我正在使用 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))
I have several thousand blobs saved in that account and I want to make the search faster in my app - is there a way to filter based on metadata?我在该帐户中保存了数千个 blob,并且希望在我的应用中加快搜索速度 - 有没有办法根据元数据进行过滤? I don't want to query all of the blobs and make a list comprehension.我不想查询所有 blob 并进行列表理解。 - thanks! - 谢谢!
Your include needs to be a list of BlobProperties:您的包含必须是 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)
reference see: https://docs.microsoft.com/de-de/python/api/azure-storage-blob/azure.storage.blob.blobproperties?view=azure-python and https://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-参考: https : //docs.microsoft.com/de-de/python/api/azure-storage-blob/azure.storage.blob.blobproperties?view=azure-python和https://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.