I am using C# in an Azure HTTP Trigger to remove an empty blob storage child folder. I have obtained the URI of the child folder and setup the security token access to the storage.
However, when I invoke the method:
blockBlob.DeleteAsync();
While this is successful, the folder is not removed?
Is there a better mechanism for removing a blob folder (that does not get removed when empty) using .NET C# approach?
Should I be passing parameters and invoking a different version of this method?
CodePudding user response:
Considering hierarchical namespace is enabled for the storage account, the SDK you would want to use is Azure.Storage.Files.DataLake
.
To delete a directory, your code would be something like (taken from here):
public void DeleteDirectory(DataLakeFileSystemClient fileSystemClient)
{
DataLakeDirectoryClient directoryClient =
fileSystemClient.GetDirectoryClient("my-directory");
directoryClient.Delete();
}