I have created a TechNet wiki article to delete all the associated VM resources. I suggest you to adopt the code and change it as per your requirement. You may comment the code which deletes the resources. Following is the link
53980.azure-delete-vm-and-all-associated-resources-using-powershell-script.aspx
Virtual machine associated resources
Az Cloud Learner
71
Reputation points
Hello Team,
I am looking for easy method to list of virtual machine's associated all resources,
Ex : on vm1, I would like to know associated NSG,ASG, OSDisk, Data disks, Subnet, vNet, NSG, Load Balancer, Associated storage account (for Diag settings),
Thank you.
2 answers
Sort by: Most helpful
-
Manu Philip 18,681 Reputation points MVP
2020-09-21T15:04:20.193+00:00 -
KarishmaTiwari-MSFT 20,212 Reputation points Microsoft Employee
2020-09-29T01:32:10.9+00:00 Please follow these guides to delete the associated resources with VM:
Let me know if you are interested in a specific associated resource.