简体   繁体   中英

Deleting a folder from blob container

I need to delete a folder from a blob container in Azure storage account. The folder structure is as follows:

container -> failed -> profiles

I am connecting to the container as follows:

CloudBlobClient blobClient = StorageAccountManager.getStorageAccount(ConnectionString));
var container = blobClient.GetContainerReference(container_name);

I am trying to refer to the specific folder as follows:

var blob = container.GetBlockBlobReference(failed + "/" + directory);

I also tried the follows ways:

((CloudBlob)blob).DeleteIfExists(); 
blob.DeleteIfExists();
blob.DeleteAsync();

but none of these are deleting the folder in my blob storage. Am I missing something or am I doing something wrong?

Folders in Azure Storage aren't really created or deleted, they exist as long as there are blobs stored in them. The way to delete a folder is to retrieve all blobs in it using ListBlobsSegmentedAsync and calling DeleteIfExists() on each of them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM