How to Delete files from azure storage using python

|
| By Webner
  1. First, install azure-storage-blob module.
    pip3 intall azure-storage-blob
  2. Then import ContainerClient:
    from azure.storage.blob import ContainerClient
  3. After that get your Credentials “Connection string” from the Microsoft official site https://portal.azure.com/#home inside the storage account option.
    azure storage
  4. 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)

Leave a Reply

Your email address will not be published. Required fields are marked *