@Richa Nagrath Welcome to Microsoft Q&A Forum, Thank you for posting your query here!
If you have data/file inside the directory, you won't be able to delete the directory through Azure Portal. You will be prompted with the error message " Failed to delete directory 'test-fileshare/test-delete/test-delete'. Error: The specified directory is not empty." You need to delete the file\folder than you can delete the directories in the Azure Portal
The most easiest and simplest way to delete the directory of Azure File Share through Storage Explorer
There is also similar thread discussion in SO forum, please refer to the suggestion mentioned in the thread
Install Azure PowerShell module:
https://learn.microsoft.com/en-us/powershell/azure/install-az-ps?view=azps-8.3.0&viewFallbackFrom=azps-2.8.0
and run below PowerShell commands to close the open handles:
Connect-AzAccount
Select-AzSubscription -Subscription <The subscription of the storage account>
Set-AzCurrentStorageAccount -ResourceGroupName <Resource group of the storage account> -Name <Storage account name>
Get-AzStorageFileHandle -sharename <file share name>-Recursive | Sort-Object ClientIP,OpenTime
Example 1: Lists all file shares of current Storage Account, and close all file handles of the file shares recursively.
Get-AzStorageShare | Close-AzStorageFileHandle -CloseAll -Recursive
Example 2: Close all file handles on a file
Close-AzStorageFileHandle -ShareName "mysharename" -Path 'dir1/dir2/test.txt' -CloseAll
This article lists common problems that are related to Microsoft Azure Files when you connect from Windows clients. It also provides possible causes and resolutions for these problems. . https://learn.microsoft.com/en-us/azure/storage/files/storage-troubleshoot-cannot-delete-files-azure-file-share
If you have any additional questions or need further clarification, please let me know.
----------
Please do not forget to
and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.