Is there someone can tell me how to fix the Error "The remote server returned an error: (409) Conflict."

Is there someone can tell me how to fix the Error "The remote server returned an error: (409) Conflict."

我使用 Automation Runbook 创建 Azure 文件的快照。我得到一个错误

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,

但并不一致。

我使用 Runbook 创建 Azure 文件快照。一开始还可以,最近出现了"The remote server returned an error: (409) Conflict."

的错误

我每天使用下面的代码创建快照。

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

我想修正错误。

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

根据与 Arthur 的讨论,我们尝试使用 try-catch 作为解决方法,因为我们没有找出根本原因。

当创建快照操作失败时,我们可以重试更多次(比如3次)。示例代码如下:

$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)