解决部署计数超出 800 的错误Resolve error when deployment count exceeds 800

每个资源组在其部署历史记录中最多只能有 800 个部署。Each resource group is limited to 800 deployments in its deployment history. 本文介绍在部署因超出允许的 800 个部署的限制而失败时可能会出现的错误。This article describes the error you receive when a deployment fails because it would exceed the allowed 800 deployments. 若要解决此错误,请从资源组历史记录中删除部署。To resolve this error, delete deployments from the resource group history. 从历史记录中删除部署不会影响已部署的任何资源。Deleting a deployment from the history doesn't affect any of the resources that were deployed.

症状Symptom

在部署过程中,你收到错误,该错误指出当前部署会超出 800 个部署的配额。During deployment, you receive an error stating that the current deployment will exceed the quota of 800 deployments.

解决方案Solution

Azure CLIAzure CLI

使用 az group deployment delete 命令从历史记录中删除部署。Use the az group deployment delete command to delete deployments from the history.

az group deployment delete --resource-group exampleGroup --name deploymentName

若要删除五天以前的所有部署,请使用:To delete all deployments older than five days, use:

startdate=$(date +%F -d "-5days")
deployments=$(az group deployment list --resource-group exampleGroup --query "[?properties.timestamp<'$startdate'].name" --output tsv)

for deployment in $deployments
do
  az group deployment delete --resource-group exampleGroup --name $deployment
done

可使用以下命令获取部署历史记录中的当前计数:You can get the current count in the deployment history with the following command:

az group deployment list --resource-group exampleGroup --query "length(@)"

Azure PowerShellAzure PowerShell

使用 Remove-AzResourceGroupDeployment 命令从历史记录中删除部署。Use the Remove-AzResourceGroupDeployment command to delete deployments from the history.

Remove-AzResourceGroupDeployment -ResourceGroupName exampleGroup -Name deploymentName

若要删除五天以前的所有部署,请使用:To delete all deployments older than five days, use:

$deployments = Get-AzResourceGroupDeployment -ResourceGroupName exampleGroup | Where-Object Timestamp -lt ((Get-Date).AddDays(-5))

foreach ($deployment in $deployments) {
  Remove-AzResourceGroupDeployment -ResourceGroupName exampleGroup -Name $deployment.DeploymentName
}

可使用以下命令获取部署历史记录中的当前计数:You can get the current count in the deployment history with the following command:

(Get-AzResourceGroupDeployment -ResourceGroupName exampleGroup).Count

第三方解决方案Third-party solutions

以下外部解决方案解决特定场景的问题:The following external solutions address specific scenarios: