Created
April 7, 2017 10:06
-
-
Save lawrencegripper/ba02e38f9723379de4721e2218995e91 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $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" | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
##[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.