blob-upload-4_4.py 695 B

12345678910
  1. def download_directory_from_blob(source, download_directory_path):
  2. container_client = ContainerClient.from_connection_string(conn_str=connect_str, container_name=container_name)
  3. print(f"\nDownloading all blobs from the following directory {source} in container {container_name}")
  4. blob_list = container_client.list_blobs()
  5. for blob in blob_list:
  6. if source in blob.name:
  7. blob_client = blob_service_client.get_blob_client(container=container_name, blob=blob.name)
  8. os.makedirs(os.path.dirname(blob.name), exist_ok=True)
  9. with open(blob.name, "wb") as download_file:
  10. download_file.write(blob_client.download_blob().readall())