How to delete a VM (virtual machine) with dependencies on Azure Stack Hub

In this article, you can find the steps to remove a VM and its dependencies from Azure Stack Hub.

If you remove a VM from Azure Stack Hub, the component dependencies--that is data disks, virtual network interfaces, and diagnostic containers--will remain in the resource group. These items won't be automatically deleted along with your OS disc. You can follow the steps in this article to successfully remove your OS disc and component dependencies.

Delete a VM overview

When you create a new VM, you typically create a new resource group and put all the dependencies in that resource group. When you want to delete the VM and all of its dependencies, you can delete the resource group. The Azure Resource Manager will successfully delete the dependencies. There are times when you cannot delete the resource group to remove the VM. For example, the VM may contain resources that are not dependencies of the VM that you would like to keep.

Delete a VM with dependencies

You can use the portal or PowerShell to remove your VM and its dependencies.

In the case where you cannot delete the resource group, either the dependencies are not in the same resource group, or there are other resources, follow the steps below:

  1. Open the Azure Stack user portal.

  2. Select Virtual machines. Find your virtual machine, and then select your machine to open the Virtual machine blade.
    Delete VM with dependencies

  3. Make a note of (write down) the resource group that contains the VM and VM dependencies.

  4. Select Networking and make a note of the networking interface.

  5. Select Disks and make a note of the OS disk and data disks.

  6. Return to the Virtual machine blade, and select Delete.

  7. Type yes to confirm the delete and select Delete.

  8. Select Resource groups and then select the resource group.

  9. Delete the dependencies by manually selecting the items you have noted. For each item, select Delete.

    1. Type yes to confirm the delete and select Delete.
    2. Wait for the resource to delete completely.
    3. You can then delete the next dependency.

Next steps

Azure Stack Hub VM features