Most (all?) of the Azure Storage Python SDK examples I've seen demonstrate creating a BlobServiceClient
in order to then create a BlobClient
for uploading / downloading blobs (ref1, ref2, etc.).
Why create a BlobServiceClient
then a BlobClient
instead of just directly creating a BlobClient
?
Example:
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)