Created
June 27, 2019 14:45
-
-
Save anyhotcountry/628c11c9bff5caed529b8058ad449cf8 to your computer and use it in GitHub Desktop.
az cli delete all resource groups without locks
This file contains 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
for i in `az group list -o tsv --query [].name`; do if [ "$(az lock list -g $i -o tsv --query [].name)" ]; then echo "$i have a lock"; else az group delete -n $i -y --no-wait; fi; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From here: https://lnx.azurewebsites.net/how-to-remove-all-empty-resource-groups-using-azure-cli/