0
votes

I use Automation Runbook to create the Azure Files' snapshot. And I get one error

Exception calling "Snapshot" with "0" argument(s): "The remote server returned an error: (409) Conflict." At line:3 char:1 + $snapshot = $share.Snapshot() + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : StorageException,

but it was not consistent.

I use the runbook to create the Azure Files snapshots. At first, it can work well, but recently there have some errors of "The remote server returned an error: (409) Conflict."

I use the code as below to create the snapshots everyday.

$context = New-AzureStorageContext -StorageAccountName "storage" -StorageAccountKey "********"
$share = Get-AzureStorageShare -Context $context -Name "test"
$snapshot = $share.Snapshot()

I want to fix the error.

Exception calling "Snapshot" with "0" argument(s): "The remote server returned an error: (409) Conflict." At line:3 char:1 + $snapshot = $share.Snapshot() + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : StorageException

1
Try updating the AzureStorage and dependent modules from Modules Gallery under your Automation Account. Modules Gallery > Search for Module > Import.tush4r
Thanks for your comment, I had checked the Azure Storage module Version (4.6.1) and found it is the newest one. Can you show me more information of the dependent modules?Arthur
Could you please confirm if you are doing any of these following 409s docs.microsoft.com/en-us/rest/api/storageservices/…tush4r
@Arthur, just for testing purpose, can you please write a new runbook, and create a new file share, then check if it can work? and also please test it from your pc to see if it works.Ivan Yang
@Arthur, why not just use try-catch in runbook? if an error throws, just create it again?Ivan Yang

1 Answers

1
votes

As per discussed with Arthur, we try to use try-catch as a workaround since we didnot figure out the root cause.

when the create snapshot operation fails, then we can retry more times(like 3 times). The sample code like below:

$RetryIntervalInSeconds = 10 
$NumberOfRetryAttempts = 2 
$CmdOk = $False 
do{ 
try{ *the code I using now $CmdOk = $True} 
catch{ * the error I met $NumberOfRetryAttempts-- Start-Sleep -Seconds $RetryIntervalInSeconds } 
} 
while (-not $CmdOk -and $NumberOfRetryAttempts -ge 0)