Blob이 Python Azure에 존재하는지 확인

Sep 15 2020

azure-storage-blob의 새 업데이트 이후 blockblobservice는 감가 상각됩니다.

Blob이 있는지 어떻게 확인할 수 있습니까?

이 답변은 새 버전의 azure-storage-blob Faster Azure Blob 이름 검색에서 Python으로 작동하지 않습니까?

GitHub에서이 문제를 발견했습니다. https://github.com/Azure/azure-sdk-for-python/issues/12744

답변

4 krishg Sep 15 2020 at 04:11

2020-09-10에 릴리스 된 버전 12.5.0 에는 이제 exists새 SDK 의 메서드가 있습니다.

예를 들면

동조:

from azure.storage.blob import BlobClient

blob = BlobClient.from_connection_string(conn_str="my_connection_string", container_name="mycontainer", blob_name="myblob")
exists = blob.exists()
print(exists)

비동기 :

import asyncio

async def check():
    from azure.storage.blob.aio import BlobClient
    blob = BlobClient.from_connection_string(conn_str="my_connection_string", container_name="mycontainer", blob_name="myblob")
    async with blob:
        exists = await blob.exists()
        print(exists)