'Can I run a Virtualbox inside a Azure VM [closed]

I am looking to find out if the following is possible.

  • Create a VM in Azure (Windows 10), install Virtual Box and start a VM in Virtualbox
  • Create a VM in Azure (Linux), install Virtual Box and start a VM in Virtualbox

Because when I try it, the VM crashes. and I am losing connection to the VM. I have tried few options from the list here sizes of vms on Microsft page Dv3 is what I tried, its not making any difference however. I am seeing statements like the nested virtualization is not support in some places, and also seeing statements like this has changed and its now supported. appreciate if anyone can comment on this as of today jan 2020

Edit: date Jan-31-2020:

I have enabled the Hyper-V and did a vagrant up and now seeing this error

> PS C:\Users\sbolla\bionictest\.vagrant> vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'hashicorp/bionic64' version '1.0.282' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Fixed port collision for 22 => 2222. Now on port 2200.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2200 (host) (adapter 1)
==> default: Booting VM...
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["startvm", "1580af6f-ce61-491c-8a8a-93dbc298cef4", "--type", "headless"]

Stderr: VBoxManage.exe: error: Raw-mode is unavailable courtesy of Hyper-V. (VERR_SUPDRV_NO_RAW_MODE_HYPER_V_ROOT)
VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component ConsoleWrap, interface IConsole
PS C:\Users\sbolla\bionictest\.vagrant>


Solution 1:[1]

Yes, you can run Virtualbox in Azure, there are 2 prerequisites to it:

  1. The host VM should be of size "v3"
  2. As per the MS article, nested virtualization is supported only on Windows 10 & Windows Server 2016. https://docs.microsoft.com/en-us/azure/virtual-machines/windows/nested-virtualization

As of 7th July 2020, nested virtualization is supported as below:

  1. VMware - No
  2. VirtualBox - Yes
  3. Hyper-V - Yes

I have tried and tested it on Windows 10 by installing Kali Linux and yes it works, both on Hyper-V & VirtualBox, but the problem I am facing is that it is quite unstable. My host reboots every now and then, and the performance of the nested VM is very bad after it is rebooted the first time. Currently, I am not sure if it is only me facing such problem or is it with everyone.

Haven't tried VirtualBox on Linux Host yet.

Solution 2:[2]

Agreed with @Falco, you need to enable the virtualization for the VM, not only create the VM with the VM size Dv3 but also need to enable it with the script or manually use the PowerShell command. See more details about the steps that How to enable nested virtualization in an Azure VM.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 SvenAelterman
Solution 2 Charles Xu