Delete a directory in DBFS recursively from Azure

Yannic
New Contributor

I have an Azure storage mounted to DBFS. I want to delete a directory inside recursively. I tried both,

dbutils.fs.rm(f"/mnt/data/to/delete", True)

and

%fs rm -r /mnt/data/to/delete

 In both cases I get the following exception:

AzureException: hadoop_azure_shaded.com.microsoft.azure.storage.StorageException: This operation is not permitted on a non-empty directory.
Caused by: StorageException: This operation is not permitted on a non-empty directory.

 How can I delete a directory recursively?

Thanks!