VirtualBox on Azure VM for testing or run Old apps
This article is about testing VirtualBox on Azure VM, the open-ource virtualization platform of Oracle. For the official nested virtualization support in Microsoft Azure please use the Nested Virtualization feature. You can find more info at my post serries about Nested Virtualization here: https://cloudcorner.gr/tag/nested-virtualization/
Virtualization has great interest and value to the information systems ecosystem. As a sence, Virtualization, refers to running two or more operating systems one one physical PC. Either the multiple operating systems run side-by-side, with a separate piece of software called a hypervisor used to manage them, or one operating system runs the other operating systems within program windows. The former is usually limited to servers, with the latter finding common use on desktop computers.
Microsoft Azure offers virtualization layer access at the following series Virtual Machines:
You can find out excactly the VM sizes that supports Virtualization at the official documentation: https://docs.microsoft.com/en-us/azure/virtual-machines/acu
Why VM virtualization on Azure?
Virtualization allows to run Old Applications, that need Operating Systems that are not officialy supported on Azure. If you have an old app that is preventing your jurney to Microsoft Azure then you can transfer your old machine that runs this application directly on Azure. Of cource you can use it for testing purposes!
Step by Step Guide
For my test I am using a Standard D2s v3 (2 vcpus, 8 GiB memory) Azure VM running Windows Server 2012 R2, as it is the most ligh Windows OS to run virtualization on Azure. You can also use Windows 10, WIndows Server 2016 & WIndows Server 2019.
Download the latest VirtualBox from the Official site, https://www.virtualbox.org/, currently 6.1
Install it with all default settings. Press yes at the Network Interfaces warning and proceed.
After the installation open the VirtualBox interface. You can add a previous created Virtual Machine from your on-premises VM, or you can create a New one.
For my test I downloaded a Windows Server 2003 Standard x86 image from my Visual Studio Subscription. Yes you can still download official Windows Server 2003 🙂
Create a new VirtualBox Virtual Machine, and select Microsoft Windows 2003 32-bit. I provided 4096 GB Ram, since it is 32-bit.
My VMs Hardware details:
Open the VM and at the “Optical Disk Selector” promt press Add and select the OS iso
And a tear droped… Windows Server 2003 setup screen, on a Virtual Machine on Azure… That runs Windows Server 2012 R2…
VirtualBox has already created a new Network Interface Card to use for the VirtualBox Virtual Machines.
You will see two IP configuration. The Ethernet adapter “Ehternet” shows the IP address of the Azure VM and the “VirtualBox Host-Only Network” shows the IP subnet that will be used for the nested VMs
Since we are inside an Azure Virtual Machine we need to use Network Address Translation to forward the traffic inside our VM. This will allow you to conenct directly to the VirtualBox VM directly from internet. This can be used for publishing a Web Service, Web Site, RDP or any other service that needs to be published from the VirtualBox nested VM.
To manage the Port Forwarding from the Host VM (Azure VM) to the Guest VM (VirtualBox VM) open the VirtualBox Preferences and go to Network
Add an Interface, add a Nertwork CIDR (the network subnet that you want the guest VMs to have) and press Port Forwarding
Now, close the VirtualBox preferences and open the VM settings and go to Network. At the Adapter 1 go select “NAT Network” and select the “NATNetwork”
After this close the VM’s settings and login to the VM. Check the IP configuration (for windows use the cms ipconfig) and you will see that the VM has been assigned an IP from the 172.16.1.0/24 range that we added at the VirtualBox NAT network. My VM has the 172.16.1.4 IP address. Note this.
Lets go back to the VirtualBox Preferences -> Network -> Edit the NatNetwork -> Port Forwarding and add a rule to forward the 443 port from the Host VM (Azure VM) to the Guest VM (VirtualBox VM).
in my example I use Prt Forward for HTTP, HTTPS & RDP. I forward HTTP & HTTPS directly but since the RDP port 3389 is already used by the Azure VM, I use 43389 Port from Azure VM to the 3389 port of the Guest VM.
Those are my rules:
There are three places that you need to open the spesified ports in order to allow the conenction to reach the VirtualBox VM. Below I will go trough the process of opening the HTTPS port 443. The same is for all other ports.
- Azure Network Security Group (NSG)
- Azure VM Windows Firewall
- VirtualBox VM Windows Firewall
1. Go to the Azure Portal, find the Network Security Group that protects the Public IP of the Azure VM and add an inbound security rule to allow access from Any source, any port, to the IP address of the Azure VM that hosts the VirutalBox and destination port 443 (for the HTTPS Web Service)
2. At the Azure VM open the Windows Firewall and add an inbound rule to allow port 443 any to any.
3. At the VirtualBox VM open the Windows Firewall and add an exception for Port 443
To test the conenctivity I just added the Application server role at my VirtualBox VM. This will publish the default IIS web page
Once the web server is ready, from my laptop I try to access the web page, usign the Public IP address of the Azure VM using https using my browser
The “Under Construction” default page of Windows Server 2003 IIS
Pantelis Apostolidis is a Cloud Solutions Architect at Microsoft and an ex Microsoft Azure MVP. For the last 15 years, Pantelis has been involved to major cloud projects in Greece and abroad, helping companies to adopt and deploy cloud technologies, driving business value. He is entitled to a lot of Microsoft Expert Certifications, demonstrating his proven experience in delivering high quality solutions. He is an author, blogger and he is acting as a spokesperson for conferences, workshops and webinars. He is also an active member of several communities as a moderator in azureheads.gr and autoexec.gr. Follow him on Twitter @papostolidis.