I am trying to clear locks on file on a schedule using Azure Automation (Powershell / Runbook). Can anyone point me in the right direction?
I have
$StorageContextfmgappservicelogs = New-AzureStorageContext -StorageAccountName 'fmgappservicelogs' -StorageAccountKey $StorageAccountKey
Get-AzStorageFileHandle -ShareName "fmgappservicelogs" -Context $StorageContextfmgappservicelogs
Close-AzStorageFileHandle -ShareName "fmgappservicelogs" -Context $StorageContextfmgappservicelogs -CloseAll
I get the following response
Get-AzStorageFileHandle : The term 'Get-AzStorageFileHandle' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
The cmdlet Get-AzStorageFileHandle
is not available in some older versions of az.storage module. So please make sure you're using the latest version az.storage module 2.6.0
.
There are some ways to install the latest version of az.storage module 2.6.0.
For example, nav to azure portal -> your azure automation account -> Modules gallery -> in the search box, search "az.storage" -> click on it, and in the new page, check if the version is the latest one -> then click "Import" button. Here are the screenshots:
You can also use some other ways to import module as per this article.