Bicep script to delete VM and it's associated resources

Narayanan, Krishnaprasad 21 Reputation points
2022-10-03T16:31:05.287+00:00

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,585 questions
0 comments No comments
{count} votes

Accepted answer
  1. Andreas Baumgarten 104K Reputation points MVP
    2022-10-03T17:08:31.813+00:00

    Hi @Krishna-0852 ,

    maybe this helps to get started: https://www.folkstalk.com/2022/09/how-to-delete-bicep-resources-with-code-examples.html

    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)

    Regards
    Andreas Baumgarten


0 additional answers

Sort by: Most helpful