0

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-1
argument --name/-n/--resource-group/-g: expected one argument
  • Does changing where you put the -y fix this? Usually the -y would come at the end of the command. – music2myear Sep 25 '22 at 04:48
  • `az group list --query "[?location=='westus']".name -o tsv | xargs -ot -n 1 az group delete -y -n` - this cmdlet worked! –  Sep 25 '22 at 15:24

1 Answers1

0

While the documentation page doesn't appear to stipulate, in most other commands I've worked with when you wish to tell the system to bypass any confirmation prompts, that argument goes at the end, last in the list.

As noted, this is not clear in the documentation I have read on this command, but as OP notes, doing this resolved the issue.

music2myear
  • 40,472
  • 44
  • 86
  • 127