How to Delete Multiple Resource Groups at Once Using Azure CLI

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.

Azure CLI Azure Resource Groups Delete Multiple Resource Groups Azure Automation Azure CLI Tutorial Azure DevOps Microsoft Azure Bulk Delete Resource Groups Azure Commands Azure for Beginners Azure Administration Azure Management Azure PowerShell vs CLI Azure Cleanup Script Delete Azure Resources Azure Tutorial 2025 Azure Cloud Tutorial Azure Resource Manager Azure CLI Commands az group delete Azure Cost Optimization Remove Resource Groups Azure Azure Batch Operations Azure Scripting Cloud Automation Azure Infrastructure Management Azure Technical Tutorial Azure Engineer DevOps Tutorial Azure Best Practices

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

Azure CLI Azure Resource Groups Delete Multiple Resource Groups Azure Automation Azure CLI Tutorial Azure DevOps Microsoft Azure Bulk Delete Resource Groups Azure Commands Azure for Beginners Azure Administration Azure Management Azure PowerShell vs CLI Azure Cleanup Script Delete Azure Resources Azure Tutorial 2025 Azure Cloud Tutorial Azure Resource Manager Azure CLI Commands az group delete Azure Cost Optimization Remove Resource Groups Azure Azure Batch Operations Azure Scripting Cloud Automation Azure Infrastructure Management Azure Technical Tutorial Azure Engineer DevOps Tutorial Azure Best Practices

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:
  1. Test Resource Groups
  2. Lab environments
  3. Practice deployments
  4. Temporary VM setups
  5. 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.

Azure CLI Azure Resource Groups Delete Multiple Resource Groups Azure Automation Azure CLI Tutorial Azure DevOps Microsoft Azure Bulk Delete Resource Groups Azure Commands Azure for Beginners Azure Administration Azure Management Azure PowerShell vs CLI Azure Cleanup Script Delete Azure Resources Azure Tutorial 2025 Azure Cloud Tutorial Azure Resource Manager Azure CLI Commands az group delete Azure Cost Optimization Remove Resource Groups Azure Azure Batch Operations Azure Scripting Cloud Automation Azure Infrastructure Management Azure Technical Tutorial Azure Engineer DevOps Tutorial Azure Best Practices


Prerequisites before doing this activity

Before starting, make sure:
  1. Azure CLI is installed
  2. You have access to an Azure Subscription
  3. 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

Azure CLI Azure Resource Groups Delete Multiple Resource Groups Azure Automation Azure CLI Tutorial Azure DevOps Microsoft Azure Bulk Delete Resource Groups Azure Commands Azure for Beginners Azure Administration Azure Management Azure PowerShell vs CLI Azure Cleanup Script Delete Azure Resources Azure Tutorial 2025 Azure Cloud Tutorial Azure Resource Manager Azure CLI Commands az group delete Azure Cost Optimization Remove Resource Groups Azure Azure Batch Operations Azure Scripting Cloud Automation Azure Infrastructure Management Azure Technical Tutorial Azure Engineer DevOps Tutorial Azure Best Practices

Method 1 – Delete Resource Groups One by One

Before Deleting Selected Resource Groups

Azure CLI Azure Resource Groups Delete Multiple Resource Groups Azure Automation Azure CLI Tutorial Azure DevOps Microsoft Azure Bulk Delete Resource Groups Azure Commands Azure for Beginners Azure Administration Azure Management Azure PowerShell vs CLI Azure Cleanup Script Delete Azure Resources Azure Tutorial 2025 Azure Cloud Tutorial Azure Resource Manager Azure CLI Commands az group delete Azure Cost Optimization Remove Resource Groups Azure Azure Batch Operations Azure Scripting Cloud Automation Azure Infrastructure Management Azure Technical Tutorial Azure Engineer DevOps Tutorial Azure Best Practices

Intializing below commands

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

Azure CLI Snapshot

Azure CLI Azure Resource Groups Delete Multiple Resource Groups Azure Automation Azure CLI Tutorial Azure DevOps Microsoft Azure Bulk Delete Resource Groups Azure Commands Azure for Beginners Azure Administration Azure Management Azure PowerShell vs CLI Azure Cleanup Script Delete Azure Resources Azure Tutorial 2025 Azure Cloud Tutorial Azure Resource Manager Azure CLI Commands az group delete Azure Cost Optimization Remove Resource Groups Azure Azure Batch Operations Azure Scripting Cloud Automation Azure Infrastructure Management Azure Technical Tutorial Azure Engineer DevOps Tutorial Azure Best Practices

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

Azure CLI Azure Resource Groups Delete Multiple Resource Groups Azure Automation Azure CLI Tutorial Azure DevOps Microsoft Azure Bulk Delete Resource Groups Azure Commands Azure for Beginners Azure Administration Azure Management Azure PowerShell vs CLI Azure Cleanup Script Delete Azure Resources Azure Tutorial 2025 Azure Cloud Tutorial Azure Resource Manager Azure CLI Commands az group delete Azure Cost Optimization Remove Resource Groups Azure Azure Batch Operations Azure Scripting Cloud Automation Azure Infrastructure Management Azure Technical Tutorial Azure Engineer DevOps Tutorial Azure Best Practices

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

Azure CLI Snapshot

Azure CLI Azure Resource Groups Delete Multiple Resource Groups Azure Automation Azure CLI Tutorial Azure DevOps Microsoft Azure Bulk Delete Resource Groups Azure Commands Azure for Beginners Azure Administration Azure Management Azure PowerShell vs CLI Azure Cleanup Script Delete Azure Resources Azure Tutorial 2025 Azure Cloud Tutorial Azure Resource Manager Azure CLI Commands az group delete Azure Cost Optimization Remove Resource Groups Azure Azure Batch Operations Azure Scripting Cloud Automation Azure Infrastructure Management Azure Technical Tutorial Azure Engineer DevOps Tutorial Azure Best Practices

Understanding 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.

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

Azure CLI Azure Resource Groups Delete Multiple Resource Groups Azure Automation Azure CLI Tutorial Azure DevOps Microsoft Azure Bulk Delete Resource Groups Azure Commands Azure for Beginners Azure Administration Azure Management Azure PowerShell vs CLI Azure Cleanup Script Delete Azure Resources Azure Tutorial 2025 Azure Cloud Tutorial Azure Resource Manager Azure CLI Commands az group delete Azure Cost Optimization Remove Resource Groups Azure Azure Batch Operations Azure Scripting Cloud Automation Azure Infrastructure Management Azure Technical Tutorial Azure Engineer DevOps Tutorial Azure Best Practices

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.


Post a Comment

Do comment let us know your valuable response towards above post

Previous Post Next Post
Youtube Channel Image
Praveen Veerapogu Subscribe To watch more Tutorials
Subscribe