[Python] How to efficiently list all files in an Azure blob using python?

Discussão em 'Python' iniciado por Stack, Julho 12, 2025.

  1. Stack

    Stack Membro Participativo

    I need to list all files in an Azure blob using python. Currently I use the code below. this worked well when there were few files. But now I have a large number of files and the script runs more than an hour. The time-consuming part is the for loop. How can this be done faster?

    import os, uuid
    from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient, __version__
    import pandas as pd

    connect_str = "************"

    blob_service_client = BlobServiceCliaent.from_connection_string(connect_str)

    blob_service_client.get_account_information()
    c = blob_service_client.list_containers()

    container_client = blob_service_client.get_container_client("blobName")

    l = []
    for blob in container_client.list_blobs():
    l.append(blob.name)

    Continue reading...

Compartilhe esta Página