Closing open files in Azure File Share

Tom Wrigglesworth 91 Reputation points
2024-07-09T16:37:08.0633333+00:00

Hello,

Is there a way to list files that are open by a user, on a particular azure file share?

We have open files that cannot be adjusted as it believes they're already open.

Kind regards

Azure Files
Azure Files
An Azure service that offers file shares in the cloud.
1,301 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Vahid Ghafarpour 21,725 Reputation points
    2024-07-09T20:03:29.4466667+00:00

    Thanks for posting your question in the Microsoft Q&A forum.

    May this thread help you:

    https://learn.microsoft.com/en-us/answers/questions/527764/how-to-view-open-files-on-azure-file-share

    You can check this script

    for account in $(az storage account list --query '[].{Name:name}' --output tsv); do
        echo $account $(az storage share list --account-name $account --output tsv | awk '{print $2}')
    done
    
    

    ** Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful **

    0 comments No comments

  2. Nehruji R 8,146 Reputation points Microsoft Vendor
    2024-07-10T11:48:30.1+00:00

    Hello Tom Wrigglesworth,

    Greetings! Welcome to Microsoft Q&A Platform.

    I understand that you would like to know about the open files in file share by a particular user. You can list open files on an Azure File Share using the PowerShell command Get-AzStorageFileHandle. This command allows you to list file handles of a file share, a file directory, or a specific file. Here’s a basic example of how you can use it:

    # Connect to your Azure account
    Connect-AzAccount
    
    # Get the storage account context
    $context = (Get-AzStorageAccount -ResourceGroupName "YourResourceGroupName" -Name "YourStorageAccountName").Context
    
    # List open file handles in the file share
    Get-AzStorageFileHandle -Context $context -ShareName "YourFileShareName" -Recursive
    You can use the PowerShell command 
    

    Using Windows tools: Handles.exe You can use Handle.exe on a Windows client to check if there are open handles on the client against the Azure File.

    Example: handle <StorageAccountName>.file.core.windows.net

    The script can however be worked further to list open handles and close a single handle etc.

    For more details: https://learn.microsoft.com/en-us/rest/api/storageservices/force-close-handles.

    Similar ask thread for reference - https://learn.microsoft.com/en-us/answers/questions/1047102/azure-files-open-files.

    Hope this answer helps! Please let us know if you have any further queries. I’m happy to assist you further.


    Please "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    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.