Azure/azure-storage-python

get md5 for blob

cometta opened this issue · 1 comments

Is there any azure api call that i can use to retrieve md5 hash for the blob inside a container?

from azure.storage.blob import BlobServiceClient

# Your connection string
connection_string = "your_connection_string"

# Your blob container name and blob name
container_name = "your_container_name"
blob_name = "your_blob_name"

# Initialize a BlobServiceClient
blob_service_client = BlobServiceClient.from_connection_string(connection_string)

# Get a reference to the blob
blob_client = blob_service_client.get_blob_client(container=container_name, blob=blob_name)

# Get the properties of the blob
blob_properties = blob_client.get_blob_properties()

# Retrieve the MD5 hash value from the properties
md5_hash = blob_properties.content_settings.content_md5

print(f"MD5 Hash of the blob: {md5_hash}")