新 AzureRmResourceGroupDeployment:"Deployment 'xxx' could not be found"

New-AzureRmResourceGroupDeployment: "Deployment 'xxx' could not be found"

我使用的是最新的 Azure Powershell,当我 运行 使用以下代码部署我的模板时开始出现此错误:

New-AzureRmResourceGroupDeployment -Name ((Get-ChildItem $TemplateFile).BaseName + '-' + ((Get-Date).ToUniversalTime()).ToString('MMdd-HHmm')) `
                                  -ResourceGroupName $ResourceGroupName `
                                  -TemplateFile $TemplateFile `
                                  -Mode $DeploymentMode `
                                  @OptionalParameters `
                                  -Force -Verbose -ErrorAction Stop

导致此错误:

VERBOSE: 7:34:35 PM - Template is valid.
VERBOSE: 7:34:35 PM - Create template deployment 'MyDeployment-0615-2331'
VERBOSE: 7:34:35 PM - Checking deployment status in 5 seconds
Microsoft.Rest.Azure.CloudException: Deployment 'MyDeployment-0615-2331' could not be found.
   at Microsoft.Azure.Management.ResourceManager.DeploymentOperationsOperations.<ListWithHttpMessagesAsync>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Management.ResourceManager.DeploymentOperationsOperationsExtensions.<ListAsync>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Management.ResourceManager.DeploymentOperationsOperationsExtensions.List(IDeploymentOperationsOperations operations, String resourceGroupName, String deploymentName, Nullable`1 top)
   at Microsoft.Azure.Commands.ResourceManager.Cmdlets.SdkClient.ResourceManagerSdkClient.WriteDeploymentProgress(String resourceGroup, String deploymentName, Deployment deployment)
   at Microsoft.Azure.Commands.ResourceManager.Cmdlets.SdkClient.ResourceManagerSdkClient.WaitDeploymentStatus(String resourceGroup, String deploymentName, Deployment basicDeployment, Action`3 job, ProvisioningState[] status)

   at Microsoft.Azure.Commands.ResourceManager.Cmdlets.SdkClient.ResourceManagerSdkClient.ProvisionDeploymentStatus(String resourceGroup, String deploymentName, Deployment deployment)
   at Microsoft.Azure.Commands.ResourceManager.Cmdlets.SdkClient.ResourceManagerSdkClient.ExecuteDeployment(PSCreateResourceGroupDeploymentParameters parameters)
   at Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupDeploymentCmdlet.ExecuteCmdlet()
   at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()

这对我来说没有任何意义,因为它不应该寻找现有的部署,它应该创建一个新的部署。从未在 Azure 中创建部署。

这是一个间歇性问题,并非一直发生,但相当频繁。

这是一个 known issue,Azure PowerShell SDK 团队正在努力修复并寻找可重现问题的模板。