Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upload image to azure blob storage using python

I have an image directory named images which contains image files as:

images
    --0001.png
    --0002.jpg
    --0003.png

Now I want to upload this directory to my azure blob storage with the same file structure. I looked at the sample code given here and here but:

  1. Even after installing azure-blob-storage, there is no such thing as BlobService in that package.
  2. Is there any place where it is clearly documented how to do this?
like image 409
enterML Avatar asked Sep 08 '26 00:09

enterML


1 Answers

It's in the documentation that you linked.

It's not BlobService, it is BlobClient class.

from azure.storage.blob import BlobClient

blob_client = BlobClient.from_connection_string(
        conn_str='my_conn_str',
        container_name='my_container_name',
        blob_name='my_blob_name')

with open("./SampleSource.txt", "rb") as data:
    blob.upload_blob(data)

See the BlobClient.from_connection_string documentation.

like image 186
Adam Marczak Avatar answered Sep 10 '26 13:09

Adam Marczak