Search code examples
azureazure-cliazure-resource-group

Delete list of Azure Resource Groups in a subscription without confirmation using Azure ClI


I want to delete all the resource groups in a subscription in a single cli command. I used pipeline operator to delete all the resource groups:

(Get-AzResourceGroup | Remove-AzResourceGroup).

While azure deletes the groups sequentially, it prompts for confirmation for each resource group. Is there a way to force delete all resource groups in Azure cli without encountering the confirmation from the CLI.


Solution

  • Please use -Force parameter to remove resource group without confirmation.

    From this link:

    Get-AzResourceGroup -Name "ContosoRG01" | Remove-AzResourceGroup -Force
    

    This command uses the Get-AzResourceGroup cmdlet to get the resource group ContosoRG01, and then passes it to Remove-AzResourceGroup by using the pipeline operator. The Force parameter suppresses the confirmation prompt.