Home > Enterprise >  How to delete all resource groups forcibly without prompt for confirmation using Azure CLI cmdlets?
How to delete all resource groups forcibly without prompt for confirmation using Azure CLI cmdlets?

Time:09-27

Found the similar Question but answer is in Azure PowerShell.

Tried the below cmdlet to delete all resource groups in particular location:

az group list --query "[?location=='westus']".name -o tsv | xargs -otl az group delete -n

It is asking me to prompt for every resource group deletion.

Also tried adding the flag -y by reading this MS Doc,

az group list --query "[?location=='westus']".name -o tsv | xargs -otl az group delete -n -y

Error:

az group delete -n -y rg-105
argument --name/-n/--resource-group/-g: expected one argument

CodePudding user response:

Please try the following:

az group list --query "[?location=='westus']".name -o tsv | xargs -ot -n 1 az group delete -y -n

Reference: https://github.com/Azure/azure-cli/issues/1398#issuecomment-276135930

  • Related