Azure File - Error Snapshot - PowerShell

Copper Contributor

Hi all,

 

I want to deploy an Azure File (Storage Account) and use it as a Shared Folder in my Windows 10, up here all right. I´ve created a Runbook to launch shares snapshot automatically everyday (PowerShell). The code used is:

 

$connectionstring="DefaultEndpointsProtocol=https;AccountName=<name>;AccountKey=<key>;EndpointSuffix=core.windows.net"
$sharename=":work"
$ctx=New-AzureStorageContext -ConnectionString $connectionstring
$share=Get-AzureStorageShare -Context $ctx -Name work
$share.Snapshot()

 

The Runbook ends with de next error: 

 

Method invocation failed because [Microsoft.WindowsAzure.Storage.File.CloudFileShare] does not contain a method named
'Snapshot'.

 

 

This error is the same when trying these code in "Windows PowerShell ISE" client, but doesn´t appear in Cloud Shell (Azure Portal).

 

Please, somebody could help me?

 

Thanks in advance.

Juanma.

1 Reply

Try importing or updating Azure.Storage module in the automation account, that worked for me.  I'm running something similar to schedule snapshots