'Create and Delete Resource Group in Azure using Bicep

Scenario :

I create a main.bicep file containing one resource group :

I scope the command to the subscription and create the resource group.

New-AzSubscriptionDeployment -TemplateFile .\main.bicep

I now want to delete the same resource group using the .bicep file , in Terraform i could do this by removing or commenting out the RG , but in Bicep it seems like the -Mode command needs to be scoped to resources in an existing RG and i cannot use the New-AzSubscriptionDeployment -Mode Complete command to remove the RG resource from Azure.

Is this a limitation of Bicep ? Does Resource Groups need to be manually removed when no longer needed ?



Solution 1:[1]

Currently, yes they need to be removed manually. This isn't so much a limitation of bicep as it is the Azure platform.

There is a capability on the horizon that will allow you to clean up empty resourceGroups, no public ETA for that but it is in private preview at the moment.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 bmoore-msft