我见过的大多数(全部?)Azure 存储 Python SDK 示例演示了创建 aBlobServiceClient
以便然后创建一个BlobClient
用于上传/下载 blob(ref1、ref2等)。
为什么要创建 a BlobServiceClient
then aBlobClient
而不是直接创建 a BlobClient
?
例子:
from azure.storage.blob import BlobClient
def create_blob_client(connection_string):
try:
blob_client = BlobClient.from_connection_string(connection_string)
except Exception as e:
logging.error(f"Error creating Blob Service Client: {e}")
return blob_client
connection_string = os.environ["CONNECTION_STRING"]
blob_client = create_blob_client(connection_string)