How To Remove All Resources in a Resource Group Without Removing the Group On Azure

Sometimes, I’ve needed to remove all the resources in a resource group without actually having to remove the resource group itself. In the Azure Portal, it’s not possible to do this other than manually selecting each resource individually and deleting it. But now that Cloud Shell has GA’d you can easily use it to accomplish the same thing. It’s really quite simple.

  1. Create a file on your computer called “removeall.json” and paste in the following contents.{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": { },
    "variables": { },
    "resources": [ ],
    "outputs": { }
    }
  2. Launch Cloud Shell in the Azure Portal.

    Cloud Shell
    Cloud Shell
  3. Select Upload to upload the file to your Cloud Shell.

    Upload File
    Upload File
  4. CD to the path that Cloud Shell indicated was the upload destination.
    Path to File
    Path to File

  5. Use the Azure CLI to remove the resources.
    az group deployment create --mode complete --template-file ./removeall.json --resource-group docker1

What this is doing is deploying an empty ARM Template to the resource group in complete mode. Complete mode does not attempt to update existing resources, rather it will remove existing resources and then recreate the resources as defined in the ARM template. But since the ARM template you deployed is empty, it will simply remove remove the existing resources and not deploying anything new, an voila, you have an empty resource group without having to recreate it.

 

We deliver solutions that accelerate the value of Azure.

Ready to experience the full power of Microsoft Azure?

Start Today

Blog Home

Stay Connected

Upcoming Events

All Events