Delete VM and resources from resource group

Chris Langford 1 Reputation point
2021-09-03T13:31:16.59+00:00

Hi,
I have recently noticed an issue whilst deleting VMs and associated resource from several resource groups using the Azure portal. In the portal when I select a VM (deallocated or running) and its resources nics, disks, ngs etc. using the select all check box, I am presented with an error stating that resources could not be deleted as they are being used by other resources in the same resource group e.g., the NSG cannot be deleted as it is being used by the NIC. This means that performing bulk delete tasks using the portal fails. This is a recent error, as I have always been able to delete multiple VMs and associated resource from within a resource group at once without having to either delete individual dependant resource first or the resource group, as the Azure portal managed the order in which resources were deleted.
Can anyone shed any light on this issue?

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,201 questions
Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,132 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. kobulloc-MSFT 23,646 Reputation points Microsoft Employee
    2021-09-03T14:38:21.9+00:00

    Hello, @Chris Langford !

    It is possible to delete all VM resources individually however there are some resources that are dependent on others:

    • Network interface requires VM deleted
    • NSG (Network Security Group), virtual network, and public IP address require network interface deleted (public IP address can be disassociated)

    For example, the NSG (Network Security Group), public IP address, and virtual network gave failed to delete errors until I deleted my network interface and my network interface gave me errors until I deleted my virtual machine.

    129164-image.png

    129165-image.png

    129176-image.png

    129183-image.png

    129143-image.png

    0 comments No comments

  2. Chris Langford 1 Reputation point
    2021-09-08T09:39:00.337+00:00

    Thanks for your response kobulloc-MSFT. I know that some resources cannot be deleted until dependant resources are deleted and in my automation script I delete resources in order to avoid this issue however, up until recently via the portal I had always been able to select multiple resource within a resource group (Vm, Nic, NSG etc), click delete and the portal would remove all the selected resources without me having to remove individual or dependant resources manually or in any order.

    0 comments No comments