Cannot retrieve path of "open files" using Get-AzStorageFileHandle

Vladimir Amirov 0 Reputation points
2024-10-23T07:36:50.7833333+00:00

Hi all,

Need to retrieve a list of open files on Azure file share and then "kill" it

I'm trying to retrieve list of files,

Get-AzStorageFileHandle -ShareName "mysharename" -Recursive | Sort-Object ClientIP,OpenTime

but cannot get a path, screenshot below:

How can I solve this issue, any help will be great. Thank you

Azure Storage
Azure Storage
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
3,529 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Abiola Akinbade 29,405 Reputation points Volunteer Moderator
    2024-10-23T07:44:16.1266667+00:00

    The "No file path available" issue might occur if:

    • The file was recently deleted but the handle is still open
    • There are permission issues accessing the file metadata
    • The handle is in an inconsistent state

    Try adding -Debug parameter to get more detailed information:

    See: https://learn.microsoft.com/en-us/powershell/module/az.storage/get-azstoragefilehandle?view=azps-12.4.0#example-1-list-all-file-handles-on-a-file-share-recursively-and-sort-by-clientip-and-opentime

    You can mark it 'Accept Answer' and 'Upvote' if this helped you

    Regards,

    Abiola

    0 comments No comments

  2. Vinod Kumar Reddy Chilupuri 4,185 Reputation points Microsoft External Staff Moderator
    2024-10-23T12:45:55.7633333+00:00

    Hi Vladimir Amirov,

    Welcome to Microsoft Q&A, thanks for posting your query.

    To resolve the issue where Get-AzStorageFileHandle is not showing files paths for open files on your Azure file share, you can follow the below steps:

    • Check your Azure PowerShell module is up to date. Sometimes, issues and missing features or bugs are resolved in the latest versions.
    Update-Module -Name Az
    
    • One of the most common reasons for not seeing file paths is due to access permissions. Make sure that your azure account has the necessary permissions to view manage files handles. You need to ensure that the account has the appropriate roles such as Storage Account Contributor.
    • Try using the command with a storage context to see if it retrieves more detailed information.
    # Create a context for your storage account
    $storageAccount = Get-AzStorageAccount -ResourceGroupName "yourResourceGroupName" -Name "yourStorageAccountName"
    $context = $storageAccount.Context
    
    # Retrieve file handles with context
    Get-AzStorageFileHandle -Context $context -ShareName "mysharename" -Recursive | Sort-Object ClientIpAddress, OpenTime
    
    • You can also verify open file handles directly through the Azure portal. Navigate to your Storage Account > File Shares. Choose your file share and go to Open handles verify if the paths are visible there.

    Please let us know if you have any further queries. I’m happy to assist you further. 


    Please do not forget to "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.