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

In this article, you can find the steps to remove a virtual machine (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, remain in the resource group. These items won't be automatically deleted along with your OS disk. Follow the steps in this article to remove your OS disc and component dependencies.

Delete a VM

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. Azure Resource Manager successfully deletes the dependencies. There are times when you cannot delete the resource group to remove the VM; for example, the VM might contain resources that are not dependencies of the VM that you want to keep.

Delete a VM with dependencies (unmanaged disks)

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

If you cannot delete the resource group, either the dependencies are not in the same resource group, or there are other resources. Follow these steps:

  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 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 then select Delete.
  8. Select Resource groups, and then select the resource group.
  9. Delete the dependencies by manually selecting the items you 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