'Access Azure storage from python
I am new to azure storage and I have a python files that needs some csv files stored in azure storage , I want to use them in the python script , how i do that exactly
Solution 1:[1]
You can setup your project to work with the Azure Blob Storage client library v12 for Python by following this link.
Use the below code to download from storage account using python:
import os, uuid
from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient, __version__
try:
print("Azure Blob Storage v" + __version__ + " - Python quickstart sample")
# Download the blob to a local file
# Add 'DOWNLOAD' before the .txt extension so you can see both files in the data directory
download_file_path = os.path.join(local_path, str.replace(local_file_name ,'.txt', 'DOWNLOAD.txt'))
print("\nDownloading blob to \n\t" + download_file_path)
with open(download_file_path, "wb") as download_file:
download_file.write(blob_client.download_blob().readall())
except Exception as ex:
print('Exception:')
print(ex)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | RajkumarMamidiChettu-MT |
