Share:
Twitter
LinkedIn
Facebook
Reddit
Whatsapp
Follow by Email
Reading Time: 5 minutes

In a previous article, I talked about how to enable Nested Virtualisation in Hyper-V running on Server 2016. As we all know a lot of Azure runs Hyper-V and some of the regions are running Server 2016. Recently Microsoft announced that they are going to bring Nested Virtualisation to Azure. This happened recently with the addition of the Dv3 and Ev3 Virtual machines sizes.

D2-64 v3 instances are the latest generation of General Purpose Instances. D2-64 v3 instances are based on the 2.3 GHz Intel Xeon ® E5-2673 v4 (Broadwell) processor and can achieve 3.5GHz with Intel Turbo Boost Technology 2.0. D2-64 v3 instances offer the combination of CPU, memory, and local disk for most production workloads.

E2-64 v3 instances are the latest generation of Memory Optimized Instances. E2-64 v3 instances are based on the 2.3 GHz Intel Xeon ® E5-2673 v4 (Broadwell) processor and can achieve 3.5GHz with Intel Turbo Boost Technology 2.0. E2-64 v3 instances are ideal for memory-intensive enterprise applications.

Thanks to the new VM sizes, we are now able to run Hyper-V Containers (Windows Containers with additional isolation) and starting with Windows Server 1709 Linux Containers in a VM in Azure. With this new feature, you also get the added benefit of being able to spin up new VMs for test, dev and lab purposes.

How to Setup Nested Virtualization In Microsoft Azure

Create An Azure VM

I am not going to walk you through the process of creating an Azure VM in this guide, but if you click here you can follow one from a previous article of mine. Just make sure you pick either a Dv3 or Ev3 VM size.

Once you have created your new VM we will need to add some storage to the VM so we have somewhere to store our nested VMs. You can create just one disk or more if you like. I prefer to utilise Storage Spaces to give me better performance so I will create two disks in this guide.

Once you have the two disks created connect up to your VM and Open Server Manager. Navigate to File and Storage Services. Then navigate to Storage Pools

Follow the wizard to create your Storage Pool

Right click on your newly created storage pool and click Create Virtual Disk and then click OK on the popup window.

Follow the wizard and choose Simple on the storage layout section.

A new wizard will pop up follow that and pick a drive letter, format type and name for your new drive.

Now we have your VM created and storage sorted its time to move on to installing Hyper-V.

Install and configure Hyper-V

First, we need to open PowerShell with elevated credentials and type the following.

Install-WindowsFeature -Name Hyper-V -IncludeManagementTools -Restart
view raw Install Hyper-V hosted with ❤ by GitHub

This will Install Hyper-V and restart your server.

Once the server comes back up we will have Hyper-V installed and ready to allow nested Virtual Machines. They will just not be able to access the Internet. We can get past this hurdle by creating a NAT Switch in Hyper-V. You can read more about NAT Switches here or follow the rest of this guide to get yourself up and running.

Configure the network

Create Virtual Switch

First, we need to create the new Hyper-V switch. Open up PowerShell with elevated credentials again and type the following.

New-VMSwitch -SwitchName "NATvSwitch" -SwitchType Internal

You can change “NATvSwitch” to whatever you want to call your NAT switch.

Configure Virtual Switch

Now we can configure the Virtual Switch with an IP Address. To do this we can use the same PowerShell window as before and type the following.

New-NetIPAddress -IPAddress 10.10.10.1 -PrefixLength 24 -InterfaceAlias "vEthernet (NATvSwitch)"

Changing the –IPAddress to something you want to use. This IP Address will become the default gateway for your NAT’ed devices.
You can also change the –InterfaceAlias to something you like also.

Create NAT Network

Now we can start to create the new NAT network. In the same PowerShell window type the following.

New-NetNAT -Name "NATvNetwork" -InternalIPInterfaceAddressPrefix 10.10.10.0/24

Changing the –Name to something you want to use. You also need to change -InternalIPInterfaceAddressPrefix to the IP range you are using. But note the IP Address you set in the previous step has to be in this range.

Now any new nested VM you create has to be within the range you stated in the above command. You could always create a Nested DHCP server that will dish out IP’s in that range.

You can also create NAT rules for include servers and ports. You can read more about this here.

Create A Nested Virtual Machine

Now you can create a nested Virtual Machine the same way you would on any Hyper-V system. It really is that easy. You could set up a nested VM as another Hyper-V host and nest even more. Not sure what the performance would be like with that. Would be fun to play around with.

So there we have it a nice easy way to create Nested Virtual Machines in Azure. I can see this being very useful for many things including being an off-site Hyper-V replica site for DR. For me I am going to build some labs to try new features Microsoft are bringing out in each new release.

If you have any questions please leave a comment below.

Share:
Twitter
LinkedIn
Facebook
Reddit
Whatsapp
Follow by Email

Pixel Robots.

I’m Richard Hooper aka Pixel Robots. I started this blog in 2016 for a couple reasons. The first reason was basically just a place for me to store my step by step guides, troubleshooting guides and just plain ideas about being a sysadmin. The second reason was to share what I have learned and found out with other people like me. Hopefully, you can find something useful on the site.

3 Comments

Leona · July 22, 2018 at 5:13 pm

Hey there. First of all, congrats on a great tutorial.
I did follow every step, but I still can’t get internet in the guest VM. Any idea why?

Leonardo Penha Mesquita · July 22, 2018 at 5:13 pm

Hey there. First of all, congrats on a great tutorial.
I did follow every step, but I still can’t get internet in the guest VM. Any idea why?

    Pixel Robots. · July 22, 2018 at 5:17 pm

    Are you able to share your virtual switch configuration and IP configuration?
    You can reach out via email if you are more comfortable. It’s Richard.Hooper@pixelrobots.co.uk

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *