File share directory

Richa Nagrath 1 Reputation point
2022-09-16T12:25:39.567+00:00

Hello Team,

Could any please help how can I delete all the directories from file share using azure portal even if the directories has sub folders and data in it.

Please advice.

Thanks

Azure Files
Azure Files
An Azure service that offers file shares in the cloud.
1,420 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. SUNOJ KUMAR YELURU 15,256 Reputation points MVP Volunteer Moderator
    2022-09-16T13:15:01.74+00:00

    Hi @Richa Nagrath

    Thanks for using Q & A forum.

    You can use Azure Storage Explorer to delete files and folders, then go to your fileshare -> right click the folder -> select delete. It can delete a non-empty folder.
    Setups to download & install storage explorer
    https://learn.microsoft.com/en-us/azure/vs-azure-tools-storage-manage-with-storage-explorer?toc=%2Fazure%2Fstorage%2Fblobs%2Ftoc.json&tabs=windows#download-and-install

    Alternate, you can use AzCopy with azcopy remove command --recursive parameter.

    Troubleshoot fileshare, unable to modify or delete

    ----

    If the Answer is helpful, please click Accept Answer & UPVOTE, this can be beneficial to other community members.

    1 person found this answer helpful.
    0 comments No comments

  2. Sumarigo-MSFT 47,466 Reputation points Microsoft Employee Moderator
    2022-09-20T06:54:34.537+00:00

    @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

    242851-image.png

    The most easiest and simplest way to delete the directory of Azure File Share through Storage Explorer

    242699-image.png

    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 242720-screenshot-2021-12-10-121802.pngand “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.