Azure Files provides fully-managed SMB (CIFS) shares, with NFS support currently in preview. They can be accessed using the appropriate filesystem driver for each platform.


File handles not being released

Bugs in the Linux CIFS driver appear to cause it to fail to release handles held over files on a CIFS share, particularly under conditions of high load. Over time this can cause the servers' view of the share's state to drift, and eventually cause lockups.

Handle management is exposed in the `Az` PowerShell module, allowing us to free the handles like so:

Import-Module Az

function Close-LocalAllAzFileShareHandles() {
        [Parameter(Mandatory = $true)]
        [string] $SubscriptionName,
        [Parameter(Mandatory = $true)]
        [string] $ResourceGroupName,
        [Parameter(Mandatory = $true)]
        [string] $StorageAccountName

    Select-AzSubscription -SubscriptionName $SubscriptionName

    $accountKey = Get-AzStorageAccountKey `
            -ResourceGroupName $ResourceGroupName `
            -Name $StorageAccountName `
        | Select-Object -First 1 -ExpandProperty Value
    $context = New-AzStorageContext `
            -StorageAccountName $StorageAccountName `
            -StorageAccountKey $accountKey
    $shares = Get-AzStorageShare -Context $context `
        | Where-Object { $_.IsSnapshot -eq $false }

    foreach ($share in $shares) {
        Get-AzStorageFileHandle `
                -ShareName $share.Name -Context $context `

        # Close all file handles on share
        # Recursive will do as it says - recursively close all files from a specific path point. If
        # Path is blank it will close handles on all files below the root.
        # To close just a single file put the file path (without the leading /) into the Path
        # argument value.
        Close-AzStorageFileHandle `
                -ShareName $share.Name -Context $context `
                -CloseAll -Path "" -Recursive -PassThru -Verbose

Close-LocalAllAzFileShareHandles `
        -SubscriptionName 'x' `
        -ResourceGroupName 'y' `
        -AccountName 'z'

For more information, see the help for the cmdlets:

  • Get-Help -Name Get-AzStorageFileHandle
  • Get-Help -Name Close-AzStorageFileHandle