Issues with Deleting Azure Deployment created with ARM Template Using CLI Commands

Iheanacho Chukwu 995 Reputation points
2024-07-22T20:04:28.9533333+00:00

I have created Azure infrastructure using an ARM template for a resource group with the Azure CLI command:

az deployment group create --resource-group demo --template-file main.json --parameters parameters.json --name serviceName

I tried deleting this deployment, as I would with terraform destroy, using the commands:

az deployment group delete --name serviceName

az deployment sub delete --name serviceName

However, it does nothing and returns no errors. When I check, the resources are still there. Does anyone have an idea of what might be wrong?

Azure Training
Azure Training
Azure: A cloud computing platform and infrastructure for building, deploying and managing applications and services through a worldwide network of Microsoft-managed datacenters.Training: Instruction to develop new skills.
1,578 questions
{count} votes

Accepted answer
  1. Manu Philip 18,321 Reputation points MVP
    2024-07-22T21:03:17.68+00:00

    Hi,

    Direct cmdlet for deleting all the resources that were deployed in a specific deployment using the arm template is not available. you can try the following azure cli code to delete the resources in the resource group

    allresources=$(az deployment group show --resource-group 'RGName>' --name 'deployment name' --query "properties.outputResources[].id" -o tsv)
    for resource in $allresources; do az resource delete --ids $resource; done
    

    Hope this helps.


    --please don't forget to upvote and Accept as answer if the reply is helpful--


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.