This website collects cookies to deliver better user experience
How to use Azure Blob Storage with Python
How to use Azure Blob Storage with Python
In this publication we will see the main methods to use with Azure Blob Storage
pip install azure-storage-blob
Blob Service Client
from os import getenv
from azure.storage.blob import BlobServiceClient
blob_service_client = BlobServiceClient.from_connection_string( getenv("AZURE_STORAGE_CONNECTION_STRING"))
defcreate_container(container:str):try: blob_service_client.create_container(container)print("success")except Exception as e:print(e.message)
Delete Container
defdelete_container(container:str):try: blob_service_client.delete_container(container)print("success")except Exception as e:print(e.message)
List Containers
defget_containers():try: containers = blob_service_client.list_containers()print([container.name for container in containers])except Exception as e:print(e.message)