Recently while deploying the source code using our CI/CD pipelines, we have got this error:
There were errors in your deployment. Error code: DeploymentQuotaExceeded.
2018-05-30T04:52:38.0042831Z ##[error]Creating the deployment ‘azuredeploy-20180430-045236-1abd’ would exceed the quota of ‘800’. The current deployment count is ‘800’, please delete some deployments before creating a new one. Please see https://aka.ms/arm-deploy for usage details.
2018-05-30T04:52:38.0051084Z ##[error]Task failed while creating or updating the template deployment.
One of the steps used by our release pipelines uses ARM template to make sure that resource being targeted has required azure configuration.
Now one can go to Azure Portal -> Open Resource Groups -> Open the Resource Group in reference -> Click on Deployments -> Select one of the deployments and click on Delete -> Click on Yes to proceed with deletion. However, this was not a fit case for us as we deploy multiple times during the day. So, I had to find the PowerShell way of doing it.
Below are the PowerShell commands needed to do the same:
#Login into Azure Resource Manager using your credentials Login-AzureRmAccount #Select the subscription in reference Select-AzureRmContext -Subscription -ErrorAction Stop #This lists all Deployments from History - all 800 Get-AzureRmResourceGroupDeployment -ResourceGroupName #This command deletes all the deployments done on the resource group Get-AzureRmResourceGroupDeployment -ResourceGroupName | Remove-AzureRmResourceGroupDeployment
You need to replace with your subscription and resource group details in above commands.