Nested Virtualization in Azure

This post has to be in common with Nested Virtualization – Albandrod’s Memory (albandrodsmemory.com)

For all those who still don’t know what is Nested virtualization, is a feature that allows us to enable the Hyper-V role within a Virtual Machine in order to host and run Virtual Machines.

So in other words, to run a virtual machine inside an Azure Virtual Machine. When and why should be used? for:

  • Non-production workloads.
  • Testing purposes. Most suitable for scenarios where several hosts are required to test configurations.
  • Training. Building virtual infrastructure for educational purposes.
  • Development. Building and providing dedicated hosts to teams for Application development.

But you hace to be aware that not all AzVM sizes allow Nested Virtualization, I recommend you to always keep an eye for any upcoming updates/changes here.

Advertisement

Nested Virtualization

Do you need to run a VM in Azure which this VM it is not supported or it’s giving problem to be upload to Azure. Use Nest Virtualization instead!
First thins to take into account:
  • You can do this on either Windows Server or Windows 10.
    Only “_V3” Azure VM’s support nested virtualisation.
Deploy a VM,  once you have logged into this VM run the followoing commands in an elevated PowerShell session:
Install the Hyper-V role:
Install-WindowsFeature -Name Hyper-V -IncludeManagementTools -Restart
Create a new network Switch
New-VMSwitch -Name “InternalNAT” -SwitchType Internal
Get the Interface Index number – take a note of this number to use next
Get-NetAdapter
Set an IP Address and create the network:
New-NetIPAddress -IPAddress 192.168.0.1 -PrefixLength 24 -InterfaceIndex 13
New-NetNat -Name “InternalNat” -InternalIPInterfaceAddressPrefix 192.168.0.0/24
Once this is complete you can then open up Hyper-V manager and create your “nested” VM, and this is where you create your Linux VM (or whatever you want). Just go and download the ISO file from the relevant website and create a new VM as per normal.
Now you only will be charged for the VM in Azure and not for the two virtual machines
That’s all