使用VS Code 和 Azure Blob Storage SDK for Python 查找 Blob 名称
下面是一个 Python 示例代码,可以在 VS Code 中使用 Azure Blob Storage SDK for Python 找到指定路径下的 BlobClient,并返回其名称:
from azure.storage.blob import BlobServiceClient
def get_blob_name(account_name, account_key, container_name, blob_path):
blob_service_client = BlobServiceClient(account_url=f'https://{account_name}.blob.core.windows.net/', credential=account_key)
container_client = blob_service_client.get_container_client(container_name)
blob_client = container_client.get_blob_client(blob_path)
return blob_client.blob_name
其中,account_name 和 account_key 是你的 Azure Blob Storage 账户的名称和密钥,container_name 是你的容器名称,blob_path 是你要查找的 Blob 的相对路径。调用这个函数,它会返回找到的 Blob 的名称。
原文地址: https://www.cveoy.top/t/topic/oN5Z 著作权归作者所有。请勿转载和采集!