5

How can I read files in the Azure blob container using Python? Im trying to read some JSON files in container for flattening them.

Im new to Azure and dont have much idea about this. I could connect to the container using "BlobServiceClient". But, Im not sure how to read the files from a folder in teh container

Thanks

2
  • Please edit your question and include the code you've written and mention any issues you're running into. Also include the version of the SDK you're using. Commented Mar 28, 2020 at 11:19
  • @Dave Is that you want to know how to download the file from Azure blob with python? Commented Mar 30, 2020 at 2:45

1 Answer 1

8

If you want to read a file from Azure blob with python, please refer to the following code

from azure.storage.blob import BlobServiceClient
connection_string=''
blob_service_client = BlobServiceClient.from_connection_string(connection_string)
container_client = blob_service_client.get_container_client("<container name>")
blob_client = container_client.get_blob_client("<blob name>")
blob_client.download_blob().readall() # read blob content as string

For more details, please refer to the document

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.