Enable nested virtualization in Azure Lab Services

Nested virtualization enables you to create a lab in Azure Lab Services that contains a multi-VM environment. To avoid that lab users need to enable nested virtualization on their lab VM and install the nested VMs inside it, you can prepare a lab template. When you publish the lab, each lab user has a lab VM that already contains the nested virtual machines.

For concepts, considerations, and recommendations about nested virtualization, see nested virtualization in Azure Lab Services.


Virtualization applications other than Hyper-V are not supported for nested virtualization. This includes any software that requires hardware virtualization extensions.


Select Large (nested virtualization) or Medium (nested virtualization) for the virtual machine size when creating the lab. Nested virtualization will not work otherwise.


  • An Azure account with an active subscription. If you don't have an Azure subscription, create a free account before you begin.

Enable nested virtualization

To enable nested virtualization on the template VM, you first connect to the VM by using a remote desktop (RDP) client. You can then apply the configuration changes by either running a PowerShell script or using Windows tools.

You can use a PowerShell script to set up nested virtualization on a template VM in Azure Lab Services. The following steps guide you through how to use the Lab Services Hyper-V scripts. The steps are intended for Windows Server 2016, Windows Server 2019, or Windows 10.

  1. Follow these steps to connect to and update the template machine.

  2. Launch PowerShell in Administrator mode.

  3. You may have to change the execution policy to successfully run the script. Run the following command:

    Set-ExecutionPolicy bypass -force
  4. Download and run the script:

    Invoke-WebRequest 'https://aka.ms/azlabs/scripts/hyperV-powershell' -Outfile SetupForNestedVirtualization.ps1


    The script may require the machine to be restarted. Follow instructions from the script and re-run the script until Script completed is seen in the output.

  5. Don't forget to reset the execution policy. Run the following command:

    Set-ExecutionPolicy default -force

You've now configured your template VM to use nested virtualization and create VMs inside it.


The Linux VM is only showing a black screen

Perform the following steps to verify your nested VM configuration:

Hyper-V doesn't start with error The virtual machine is using processor-specific xsave features not supported

  • This error can happen when a lab user leaves the Hyper-V VM in the saved state. You can right-select the VM in Hyper-V Manager and select Delete saved state.


    Deleting the saved state means that any unsaved work is lost, but anything saved to disk remains intact.

  • This error can happen when the Hyper-V VM is turned off and the VHDX file is corrupted. If the lab user has created a backup of the VDHX file, or saved a snapshot, they can restore the VM from that point.

It's recommended that Hyper-V VMs have their automatic shutdown action set to shutdown.

Hyper-V is too slow

Increase the number vCPUs and memory that is assigned to the Hyper-V VM in Hyper-V Manager. The total number of vCPUs can't exceed the number of cores of the host VM (lab VM). If you're using variable memory, the default option, increase the minimum amount of memory assigned to the VM. The maximum amount of assigned memory (if using variable memory) can exceed the amount of memory of the host VM. This allows greater flexibility when having to complete intensive operations on just one of the Hyper-V VMs.

If you're using the Medium (Nested Virtualization) VM size for the lab, consider using the Large (Nested Virtualization) VM size instead to have more compute resources for each lab VM.

Internet connectivity isn't working for nested VMs

  • Confirm that you followed the previous steps for enabling nested virtualization. Consider using the PowerShell script option.

  • If you're running a system administration class, consider not using the host VM (lab VM) as the DHCP server.

    Changing the settings of the lab VM can cause issues with other lab VMs. Create an internal or private NAT network and have one of the VMs act as the DHCP, DNS, or domain controller. Using private over internal does mean that Hyper-V VMs don't have internet access.

  • Check the network adapter settings for the Hyper-V VM:


The ping command from a Hyper-V VM to the host VM doesn't work. To test internet connectivity, launch a web browser and verify that the web page loads correctly.

Next steps

Now that you've configured nested virtualization on the template VM, you can create nested virtual machines with Hyper-V. See Microsoft Evaluation Center to check out available operating systems and software.