Azure Blob Storage does not really have the concept of folders. The hierarchy is very simple: storage account > container > blob.
I have 2 ways for this
WAY - 1
we can delete a specific Blob from the container by using delete method as follows:
public void DeleteBlob()
{
var _containerName = "appcontainer";
string _storageConnection = CloudConfigurationManager.GetSetting("StorageConnectionString");
CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(_storageConnection);
CloudBlobClient _blobClient = cloudStorageAccount.CreateCloudBlobClient();
CloudBlobContainer _cloudBlobContainer = _blobClient.GetContainerReference(_containerName);
CloudBlockBlob _blockBlob = _cloudBlobContainer.GetBlockBlobReference("f115a610-a899-42c6-bd3f-74711eaef8d5-.jpg");
//delete blob from container
_blockBlob.Delete();
}
Delete Action will be:
public ActionResult DeleteBlob()
{
imageService.DeleteBlob();
return View();
}
WAY - 2
Listing the blobs within the required container, you can then delete them individually
CloudStorageAccount storageAccount = CloudStorageAccount.Parse("your storage account");
CloudBlobContainer container = storageAccount.CreateCloudBlobClient().GetContainerReference("pictures");
foreach (IListBlobItem blob in container.GetDirectoryReference("users").ListBlobs(true))
{
if (blob.GetType() == typeof(CloudBlob) || blob.GetType().BaseType == typeof(CloudBlob))
{
((CloudBlob)blob).DeleteIfExists();
}
}
For further more analysis you can refer the following links link 1 link 2.