Bicep script to delete VM and it's associated resources

Narayanan, Krishnaprasad 21 Reputation points

Could you please help me with the script to delete the VM and it's associated resource (OS Disk, Data Disks, NIC, etc) using Bicep.

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,283 questions
0 comments No comments
{count} votes

Accepted answer
  1. Andreas Baumgarten 98,626 Reputation points MVP

    Hi @Krishna-0852 ,

    maybe this helps to get started:

    If an empty Bicep file will delete all resources this way it should be possible to delete a VM and associated resources as well. Just delete the VM details and associated resources in the Bicep file you used to deploy the resources and run az deployment group create -f ./<your main.bicep file> -g <your resourcegroupname> --mode Complete .

    I would recommend to run a test first!


    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Andreas Baumgarten

0 additional answers

Sort by: Most helpful