Search code examples
pythonazureazure-blob-storageazure-storage-account

How can I obtain Etag of a file in a storage account using Python SDK for Azure?


I want to get the etag associated with a file which is uploaded in my storage account in my python code.


Solution

  • Please use the code below:

    from azure.storage.blob import BlockBlobService
    
    block_blob_service = BlockBlobService(account_name='xx', account_key='xx')
    
    myetag = block_blob_service.get_blob_properties("your_container","the_blob_name").properties.etag
    
    print(myetag)
    

    Test result:

    enter image description here