2

We are trying to get content-md5 property from azure blob, it is always returning null even we see the content-md5 value in azure container properties.

We are using python api for this, going thru the blob list and reading the blob properties,

container_client = blob_service_client.get_container_client("***")

blobs_list = container_client.list_blobs()

for props in blobs_list:
        
      blob_with_md5[props.get("name")] = props.get("CONTENT-MD5")

Do we need to enable this property readable in Azure? or do we need to use another python method for this? Any help would be appreciated.

Gaurav Mantri
  • 128,066
  • 12
  • 206
  • 241

1 Answers1

0

Please try something like the following:

container_client = blob_service_client.get_container_client("***")

blobs_list = container_client.list_blobs()

for blob in blobs_list:
    blob_content_settings = blob.content_settings
    blob_with_md5[props.get("name")] = blob_content_settings.content_md5

Reference:

BlobProperties: https://learn.microsoft.com/en-us/python/api/azure-storage-blob/azure.storage.blob.blobproperties?view=azure-python

ContentSettings: https://learn.microsoft.com/en-us/python/api/azure-storage-blob/azure.storage.blob.contentsettings?view=azure-python

Gaurav Mantri
  • 128,066
  • 12
  • 206
  • 241