用來佈建 Windows 和 Linux 虛擬機器的 Azure 服務。
Hi @Donnie Wu Since you already confirmed there is no resource group lock and deployment grooming is not disabled, please verify that the identity performing the deployment has the Microsoft.Resources/deployments/delete permission. Azure performs automatic cleanup under the deploying user or service principal identity, and if that identity lacks this permission, older deployments are not deleted automatically.
Also check for any CanNotDelete lock at the subscription scope, and consider whether many concurrent deployments are occurring, as Microsoft documentation notes that automatic deletion may not complete quickly enough when many deployments run at the same time.
To unblock the resource group manually delete older deployment history entries:
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. This example requires a Bash environment.
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 -Property Timestamp -LT -Value ((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
Please refer the documents:
Automatic deletions from deployment history
Resolve error when deployment count exceeds 800.
After you have completed the steps above, if the issue still persists, please send us the details requested in a private message so we can look into it further.
If you have further questions regarding this answer, feel free to click "Comment". If you find the answer helpful, please click "upvote". This helps the community by allowing others with similar queries to easily find the solution.