Building a nested virtual machine in Azure: Part 1

This is the first blog post of a series, that guides you through the steps of setting up an nested virtualization Azure virtual machine. We’ll start by planning and explaining the infrastructure.

What is nested virtualization?

Nested virtualization is a functionality that enables the operation of a hypervisor within a virtual machine.

If we refer to an image from the Microsoft Learn article on nested virtualization we can better visualize the concept.

Nested Virtualization

I leverage nested virtualization primarily for constructing lab environments, especially when physical hardware is unavailable in my home.

Which Azure machine sizes are compatible with nested virtualization?

  • D_v3
  • Ds_v3
  • Dv4
  • Dsv4

and so on. The full list is documented here.

The Infrastructure

This is the infrastructure that we are going to build in this series.

Nested Virtualization

We will detail each component of this infrastructure.

Public Ip

To establish a connection to our environment, a static public IP address in the standard SKU is required.

Virtual Network and Subnet

An Azure Virtual Network (VNet) is a fundamental building block in Microsoft Azure, providing a logically isolated and securely connected network in the cloud.

In this scenario, we create the IPv4 address range Within the Azure Virtual Network, we set up a subnet named nestedvm-snet, starting at the address The subnet is configured with a size of /24, providing a total of 256 addresses.


We will use a standard Azure public loadbalancer.

We will generate the following NAT rules:

OutboundInternetVirtual Machine
Inbound61412 (RDP High Port)Virtual Machine
By default, standard load balancers and standard public IP addresses block inbound connections unless explicitly allowed by Network Security Groups (NSGs). An Azure standard Loadbalancer is not open to the internet by default.

Network Security Group (NSG)

In order to enable Remote Desktop Protocol (RDP) access to our Azure Virtual Machine, it is necessary to permit traffic originating from the Load Balancer’s high port NAT Rule and direct it to the standard RDP port 3389.

Virtual Machine

In the context of my setup, I’ve chosen the Azure Virtual Machine Size Standard_D4s_v4, which provides 4 cores and 16 GB of RAM. To optimize costs, I’ve used an Azure Spot instance.

Azure Spot Instances allow users to take advantage of unused Azure compute capacity at a significantly lower cost compared to regular (on-demand) virtual machines. However, it's essential to note that the availability of Spot Instances is subject to Azure's surplus capacity.

The virtual machine’s storage utilizes a 1 TB Standard HDD Managed disk.

Cost Breakdown

Public IP AddressStandard3.32 € 
Virtual Network-0.00 € 
Load BalancerExternal4.55 €1TB traffic per month included.
Virtual MachineStandard_D4s_v427.55 €A Spot VM is used. The normal price would is 275.22 €
Standard HDD1 TB37.30 € 
Price per Month 72.72 € 

Part 1 wraps up at this point. Moving on to Part 2, we set up GitHub to facilitate the deployment of our infrastructure on Microsoft Azure.

This post is licensed under CC BY 4.0 by the author.