Blog

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

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

    Upload File

  4. CD to the path that Cloud Shell indicated was the upload destination.
    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.

 

Blaize Stewart

Recent Posts

8-Step AWS to Microsoft Azure Migration Strategy

Microsoft Azure and Amazon Web Services (AWS) are two of the most popular cloud platforms.…

1 day ago

How to Navigate Azure Governance

 Cloud management is difficult to do manually, especially if you work with multiple cloud…

1 week ago

Why Azure’s Scalability is Your Key to Business Growth & Efficiency

Azure’s scalable infrastructure is often cited as one of the primary reasons why it's the…

3 weeks ago

Unlocking the Power of AI in your Software Development Life Cycle (SDLC)

https://www.youtube.com/watch?v=wDzCN0d8SeA Watch our "Unlocking the Power of AI in your Software Development Life Cycle (SDLC)"…

1 month ago

The Role of FinOps in Accelerating Business Innovation

FinOps is a strategic approach to managing cloud costs. It combines financial management best practices…

1 month ago

Azure Kubernetes Security Best Practices

Using Kubernetes with Azure combines the power of Kubernetes container orchestration and the cloud capabilities…

2 months ago