Skip to content

folders are no longer deleted after all the files are deleted #40061

Open
@kocsszi

Description

@kocsszi
  • Package Name: azure-storage-blob
  • Package Version: 12.25.0
  • Operating System: Ubuntu
  • Python Version: 3.12

Describe the bug
When I create blobs in to a container with folders in their name, i.e. folder/file.txt when I delete folder/file.txt the folder sticks around.

To Reproduce

def upload_blob_file(container_name: str, file_path: str, blob_name: str):
    blob_service_client = get_blob_serive_client()
    container_client = blob_service_client.get_container_client(container=container_name)
    with open(file=file_path, mode="rb") as data:
        blob_client = container_client.upload_blob(name=blob_name, data=data, overwrite=True, connection_timeout=7200)

def delete_blob(container_name, blob_name):
    """
    Delete a blob from a container.
    """
    blob_service_client = get_blob_serive_client()
    container_client = blob_service_client.get_container_client(container_name)
    blob_client = container_client.get_blob_client(blob_name)
    blob_client.delete_blob()

container_name = 'your container'
file_path = 'local file path'
blob_path = 'folder/text.txt'

upload_blob_file(container_name, file_path, blob_path)
delete_blob(container_name, blob_path)

Expected behavior
When all files are deleted from the virtual folder the virtual folder gets deleted as well.

Additional context
the numerous empty folders make listing blobs unnecessary long and slow.

Metadata

Metadata

Labels

ClientThis issue points to a problem in the data-plane of the library.Service AttentionWorkflow: This issue is responsible by Azure service team.StorageStorage Service (Queues, Blobs, Files)customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions