Prepare the Azure VM Host for Nested Virtualization
VM Size Selection and Prerequisites
To set up nested virtualization, which allows running Hyper-V inside an Azure virtual machine, you must first select a compatible virtual machine size. You should choose either the Large (nested virtualization) or Medium (nested virtualization) size during deployment. Before beginning, make sure you have an active Azure subscription and a configured Azure lab plan. You will also need specific Azure role-based access control (RBAC) permissions, such as the Lab Creator, Owner, Contributor, or Lab Services Contributor role, to manage the environment.
Enabling Hyper-V via PowerShell
Once the host virtual machine is running, you configure it by establishing a Remote Desktop (RDP) connection to the template VM. To enable the hypervisor features, you must run Windows PowerShell with administrative privileges. You begin by temporarily bypassing the execution policy to allow setup scripts to run on the system. After downloading and running the official configuration script, the host installs the Hyper-V role and configures the virtual switch needed for inner guest VMs to communicate.
To prepare the VM host, complete the following steps:
- Connect to the template VM using RDP.
- Open PowerShell as an administrator.
- Run
Set-ExecutionPolicy bypass -force to allow the setup script to run.
- Download and execute the nested virtualization script from the designated URL.
- Restart the VM if prompted, then reset the execution policy using
Set-ExecutionPolicy default -force.
Use Cases and Hardware Requirements
Nested virtualization is highly beneficial for creating isolated training environments and testing complex software deployments. By utilizing Hyper-V isolation, developers can run containerized applications with an extra layer of security. This capability relies on physical hardware features, specifically modern processors that support Intel VT-x or AMD-V virtualization extensions. The Azure hypervisor passes these hardware extensions directly down to the outer VM, enabling it to act as a host for inner guest VMs.