While working on my Azure lab environment recently, I created multiple Resource Groups across different regions for testing and learning purposes. After completing the testing, deleting each Resource Group manually from the Azure Portal felt very time-consuming.
That’s when I used Microsoft Azure CLI to delete multiple Resource Groups at once, and honestly, it saved a lot of time.
In this article, I’ll share the simple method I used to bulk delete Azure Resource Groups using Azure CLI.
Resource Groups, which I have created for test purposes
Why I Needed This
If you are learning Azure, doing cloud practice, testing ARM templates, Terraform, monitoring tools, or creating temporary environments, you may end up with many Resource Groups, like:
- Test Resource Groups
- Lab environments
- Practice deployments
- Temporary VM setups
- Monitoring or DevOps testing resources
Deleting them one by one from the Azure Portal is not practical, especially when there are many Resource Groups.
What is a Resource Group in Azure
A Resource Group in Azure is basically a container that holds related resources together. For example:
- Virtual Machines
- Storage Accounts
- Databases
- Virtual Networks
- App Services
When we delete a Resource Group, all the resources inside it will also be deleted automatically. So always double-check before running the delete command. You can refer to the snapshot below for the resource group overview.
Prerequisites before doing this activity
Before starting, make sure:
- Azure CLI is installed
- You have access to an Azure Subscription
- You are logged into Azure CLI
Login command: (Bash)
az login
To verify your subscription: (Bash)
az account show
Please refer to the snapshot below for reference
Method 1 – Delete Resource Groups One by One
Intializing below commands
Better Method – Delete Multiple Resource Groups Using a Loop
Initially, I tried this method in Bash
az group delete --name rg-dt-ynm15445-italynorth --yes --no-wait
az group delete --name rg-dt-ynm15445-japaneast --yes --no-wait
az group delete --name rg-dt-ynm15445-japanwest --yes --no-wait
Note: This works fine, but when there are many Resource Groups, it becomes repetitive.
Better Method – Delete Multiple Resource Groups Using a Loop
This is the easiest and cleanest approach. That you have to execute in Bash, I am gonna delete the below bulk resource groups
Execute the command below in Azure CLI (Bash)
for rg in \rg-dt-ynm15445-koreacentral \rg-dt-ynm15445-koreasouth \rg-dt-ynm15445-malaysiawest \rg-dt-ynm15445-mexicocentral \rg-dt-ynm15445-newzealandnorth \rg-dt-ynm15445-northcentralus \rg-dt-ynm15445-northeurope \rg-dt-ynm15445-norwayeast \rg-dt-ynm15445-polandcentral \rg-dt-ynm15445-qatarcentraldo az group delete --name $rg --yes --no-waitdoneUnderstanding the Command
--yes
- Skips the confirmation prompt.
--no-wait- Runs the deletion process in the background instead of waiting for completion.
This is especially helpful when deleting large environments.
This is the easiest and cleanest approach. That you have to execute in Bash, I am gonna delete the below bulk resource groups
Execute the command below in Azure CLI (Bash)
for rg in \
rg-dt-ynm15445-koreacentral \
rg-dt-ynm15445-koreasouth \
rg-dt-ynm15445-malaysiawest \
rg-dt-ynm15445-mexicocentral \
rg-dt-ynm15445-newzealandnorth \
rg-dt-ynm15445-northcentralus \
rg-dt-ynm15445-northeurope \
rg-dt-ynm15445-norwayeast \
rg-dt-ynm15445-polandcentral \
rg-dt-ynm15445-qatarcentral
do
az group delete --name $rg --yes --no-wait
done
Understanding the Command
--yes
- Skips the confirmation prompt.
- Runs the deletion process in the background instead of waiting for completion.
How to Check Remaining Resource Groups
After deletion, I verified the remaining Resource Groups using the following command: Please refer to the Azure CLI Snapshot below
az group list --output table
1. Deletion is Permanent
Once a Resource Group is deleted, all resources inside it are removed permanently.
2. Check Before Running
Always verify the Resource Group names before executing the command.
3. Locks Can Prevent Deletion
If a Resource Group has a Delete Lock enabled, Azure will not allow deletion until the lock is removed.
After deletion, I verified the remaining Resource Groups using the following command: Please refer to the Azure CLI Snapshot below
az group list --output table
az group list --output table
1. Deletion is Permanent
Once a Resource Group is deleted, all resources inside it are removed permanently.
2. Check Before Running
Always verify the Resource Group names before executing the command.
3. Locks Can Prevent Deletion
If a Resource Group has a Delete Lock enabled, Azure will not allow deletion until the lock is removed.








