I was reading this tutorial but I cannot find a way to list all the (virtual) folder under a container without getting all the files. I have 26K files in 500 (virtual) folders. I just want to get the list of folder without having to wait few minutes to get the output of list_blobs containing the entire file list. Is there a way to do that? or at least tell list_blobs to not go deeper than n levels below a container?
Perhaps it's not too late for someone. list_blobs doesn't accept a delimiter argument. Instead, use walk_blobs (doc) to get a generator with the files. Using delimiter="/" you will get the next sublevel of files/folders:
For example:
blob_service_client = BlobServiceClient.from_connection_string(file_connect_str)
container_client = blob_service_client.get_container_client(container_name)
for file in container_client.walk_blobs('my_folder/', delimiter='/'):
print(file.name)
will return:
"my_folder/sub_folder_1/"
"my_folder/sub_folder_2/"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With