Skip to content

Instantly share code, notes, and snippets.

@lawrencegripper
Created April 7, 2017 10:06
Show Gist options
  • Select an option

  • Save lawrencegripper/ba02e38f9723379de4721e2218995e91 to your computer and use it in GitHub Desktop.

Select an option

Save lawrencegripper/ba02e38f9723379de4721e2218995e91 to your computer and use it in GitHub Desktop.
$resourceGroupName = "some-deployment-group"
Login-AzureRmAccount
Save-AzureRmProfile "$PSScriptRoot\.azureprofile"
function Delete-History {
$batch = 80
Get-AzureRmResourceGroupDeployment -ResourceGroupName $resourceGroupName | ForEach-Object {
$batch = $batch -1
Start-Job -ScriptBlock {
param($deployment)
Select-AzureRmProfile -Path "$PSScriptRoot\.azureprofile"
$deployment | Remove-AzureRmResourceGroupDeployment
} -ArgumentList $_
if ($batch -lt 0){
continue
}
}
}
$runningJobCount = (Get-job | ?{ $_.State -ne "Completed"} | Measure).Count
$remainingHistory = (Get-AzureRmResourceGroupDeployment -ResourceGroupName $resourceGroupName).Count
while ($remainingHistory -gt 0){
if ($runningJobCount -lt 5){
Delete-History
} else {
sleep -Seconds 15
}
$runningJobCount = (Get-job | ?{ $_.State -ne "Completed"} | Measure).Count
$remainingHistory = (Get-AzureRmResourceGroupDeployment -ResourceGroupName $resourceGroupName).Count
Write-host "Running jobs $runningJobCount Remaining Histories $remainingHistory"
}
@lawrencegripper
Copy link
Author

##[error]Creating the deployment 'xxxxx' 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment