Bulk Delete All Azure Resources
Sometimes you need a fresh start. Your personal account in Azure is no exception. Instead of painstakingly using the Azure Portal to delete each resource one at a time, here's a quick way to do it.
Disclaimer
This will delete all resources and resource groups in Azure. Please make sure you are using the right subscription in the Azure CLI! As far as I know there is no way to undo this.
You can check the current subscription by running az account show
Prerequisites
You will need the following command line tools installed:
- Azure CLI:
brew install azure-cli
- jq:
brew install jq
Delete all resources
for r in `az resource list -o json | jq -r ".[]|.id"`; do echo "Deleting ${r}"; az resource delete --ids ${r}; done
Delete all resource groups
for rg in `az group list | jq -r ".[]|.name"`; do echo Deleting ${rg}; az group delete -n ${rg} -y; done