Azure File - Error Snapshot - PowerShell

%3CLINGO-SUB%20id%3D%22lingo-sub-150438%22%20slang%3D%22en-US%22%3EAzure%20File%20-%20Error%20Snapshot%20-%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-150438%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20all%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20want%20to%26nbsp%3Bdeploy%26nbsp%3Ban%20Azure%20File%20(Storage%20Account)%20and%20use%20it%20as%20a%20Shared%20Folder%20in%20my%20Windows%2010%2C%20up%20here%20all%20right.%20I%C2%B4ve%20created%20a%20Runbook%20to%26nbsp%3Blaunch%20shares%20snapshot%20automatically%20everyday%20(PowerShell).%20The%20code%20used%20is%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%0A%3CDIV%3E%3CEM%3E%24connectionstring%3D%22DefaultEndpointsProtocol%3Dhttps%3BAccountName%3D%3CSTRONG%3E%3CNAME%3E%3C%2FNAME%3E%3C%2FSTRONG%3E%3BAccountKey%3D%3CSTRONG%3E%3CKEY%3E%3C%2FKEY%3E%3C%2FSTRONG%3E%3BEndpointSuffix%3Dcore.windows.net%22%3C%2FEM%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CEM%3E%24sharename%3D%22%3Awork%22%3C%2FEM%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CEM%3E%24ctx%3DNew-AzureStorageContext%20-ConnectionString%20%24connectionstring%3C%2FEM%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CEM%3E%24share%3DGet-AzureStorageShare%20-Context%20%24ctx%20-Name%20work%3C%2FEM%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CEM%3E%24share.Snapshot()%3C%2FEM%3E%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20Runbook%20ends%20with%20de%20next%20error%3A%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CEM%3EMethod%20invocation%20failed%20because%20%5BMicrosoft.WindowsAzure.Storage.File.CloudFileShare%5D%20does%20not%20contain%20a%20method%20named%20%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E'Snapshot'.%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20error%20is%20the%20same%20when%20trying%20these%20code%20in%20%22Windows%20PowerShell%20ISE%22%20client%2C%20but%20doesn%C2%B4t%20appear%20in%26nbsp%3BCloud%20Shell%20(Azure%20Portal).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPlease%2C%26nbsp%3Bsomebody%20could%20help%20me%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThanks%20in%20advance.%3C%2FP%3E%0A%3CP%3EJuanma.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-150438%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EData%20%26amp%3B%20Storage%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EStorage%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-169897%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20File%20-%20Error%20Snapshot%20-%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-169897%22%20slang%3D%22en-US%22%3E%3CP%3ETry%20importing%20or%20updating%20Azure.Storage%20module%20in%20the%20automation%20account%2C%20that%20worked%20for%20me.%26nbsp%3B%20I'm%20running%20something%20similar%20to%20schedule%20snapshots%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Visitor

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
Highlighted

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