I know we can create infrastructure using ARM templates. Can we do the same for deleting the Resources. I dont want to delete all the entire resource group but few resources in a resource group. Is this possible through ARM Templates?
Asked
Active
Viewed 5,130 times
1 Answers
5
Sort of. When you deploy an ARM template you can do it in two modes, Incremental or Complete. Incremental is the default and will add resources to a resource group and change the configuration on existing ones, but it will not delete them. If you switch your ARM template deployment to using the Complete mode, then it will make your resource group match exactly what is in your ARM template, and remove anything that is outside of that.
Obviously, you need to be careful with this.
To do a Complete deployment in PowerShell run this command
New-AzureRMResourceGroupDeployment -name "deploymentName" -resourceGroup "resourceGroupName" -templateFile "path to template" -mode complete
Sam Cogan
- 38,158
- 6
- 77
- 113
-
1The issue I see with the above answer is that you would have had to deploy everything in the resource group in a single template. If you haven't then this isn't going to work is it? Any other suggestions as I'm looking for an answer to this as well – Wayno Mar 08 '19 at 05:35