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.
Azure Resource Manager automatically deletes deployments from your history as you near the limit. You may still see this error for one of the following reasons:
- You have a CanNotDelete lock on the resource group that prevents deletions from the deployment history.
- You've opted out of automatic deletions.
- You have a large number of deployments running concurrently and the automatic deletions aren't processed fast enough to reduce the total number.
For information about removing the lock or opting in to automatic deletions, see Automatic deletions from deployment history.
This article describes how to manually delete deployments from the history.
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 deployment group delete command to delete deployments from the history.
az deployment group delete --resource-group exampleGroup --name deploymentName
To delete all deployments older than five days, use:
startdate=$(date +%F -d "-5days")
deployments=$(az deployment group list --resource-group exampleGroup --query "[?properties.timestamp<'$startdate'].name" --output tsv)
for deployment in $deployments
do
az deployment group delete --resource-group exampleGroup --name $deployment
done
You can get the current count in the deployment history with the following command:
az deployment group 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: