Resolve error when deployment count exceeds 800

Each resource group is limited to 800 deployments in its deployment history. 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

During deployment, you receive an error stating that the current deployment will exceed the quota of 800 deployments.

Solution

Azure CLI

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 PowerShell

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: