This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can trysigning in orchanging directories.
Access to this page requires authorization. You can trychanging directories.
This article shows you how to delete a virtual machine (VM) from a lab or delete a lab in Azure DevTest Labs.
When you create a VM in a lab, DevTest Labs automatically creates resources for the VM, like a disk, network interface, and public IP address, in a separate resource group. Deleting the VM deletes most of the resources created at VM creation, including the VM, network interface, and disk. However, deleting the VM doesn't delete:
Caution
Deleting VMs and labs is permanent, and cannot be undone.
To delete a VM from a lab:
On the lab'sOverview page in the Azure portal, find the VM you want to delete in the list underMy virtual machines.
Either:

or

On theAre you sure you want to delete it? page, selectDelete.
The deletion of the VM, it's network interface, and it's associated OS disks is permanent, and cannot be undone.

To check deletion status, select theNotifications icon on the Azure menu bar.
As a lab owner, you can delete VMs from your lab in the Azure portal. You also can delete all the VMs in your lab by using a PowerShell script. In the following example, under thevalues to change comment, modify the parameter values. You can retrieve thesubscriptionId,labResourceGroup, andlabName values from the lab pane in the Azure portal.
# Delete all the VMs in a lab. # Values to change: $subscriptionId = "<Enter Azure subscription ID here>" $labResourceGroup = "<Enter lab's resource group here>" $labName = "<Enter lab name here>" # Sign in to your Azure account. Connect-AzAccount # Select the Azure subscription that has the lab. This step is optional # if you have only one subscription. Select-AzSubscription -SubscriptionId $subscriptionId # Get the lab that has the VMs that you want to delete. $lab = Get-AzResource -ResourceId ('subscriptions/' + $subscriptionId + '/resourceGroups/' + $labResourceGroup + '/providers/Microsoft.DevTestLab/labs/' + $labName) # Get the VMs from that lab. $labVMs = Get-AzResource | Where-Object { $_.ResourceType -eq 'microsoft.devtestlab/labs/virtualmachines' -and $_.Name -like "$($lab.Name)/*"} # Delete the VMs. foreach($labVM in $labVMs) { Remove-AzResource -ResourceId $labVM.ResourceId -Force }When you delete a lab from a resource group, DevTest Labs automatically deletes:
DevTest Labs doesn't delete the lab's resource group itself, and doesn't delete any resources you manually created in the lab's resource group.
Note
If you want to manually delete the lab's resource group, you must delete the lab first. You can't delete a resource group that has a lab in it.
To delete a lab:
On the lab'sOverview page in the Azure portal, selectDelete from the top toolbar.

On theAre you sure you want to delete it? page, underType the lab name, type the lab name, and then selectDelete.
The deletion of the lab and all its resources is permanent, and cannot be undone.

To check deletion status, select theNotifications icon on the Azure menu bar.

Was this page helpful?
Need help with this topic?
Want to try using Ask Learn to clarify or guide you through this topic?
Was this page helpful?
Want to try using Ask Learn to clarify or guide you through this topic?