- First, install azure-storage-blob module.
pip3 intall azure-storage-blob
- Then import ContainerClient:
from azure.storage.blob import ContainerClient
- After that get your Credentials “Connection string” from the Microsoft official site https://portal.azure.com/#home inside the storage account option.
- After that just follow the below-mentioned code:
from azure.storage.blob import ContainerClient
def delete_files_from_azure_storage():
CONNECT_STR = "Def*******************************************
*************net"
CONTAINER_NAME = "Enter container name here"
container_client = ContainerClient.from_connection_string(conn_str=
CONNECT_STR, container_name=CONTAINER_NAME)
all_files_list=container_client.list_blobs("")
for blob in all_files_list:
container_client.delete_blob(blob=blob.name)
How to Delete files from azure storage using python
|