Create a RHEL Developer VM in Azure

Step 1: Download RHEL ISO and prepare VHD to be upload to Azure

Step 2: Create Storage Account and Upload the VHD to Azure

Step 3: Create a virtual machine based out of the custom VHD

Step 4: Test your Virtual Machine

Step 1: Download RHEL ISO and prepare VHD to be upload to Azure

You can download the ISO from RedHat developer portal. Once you download the ISO, our next step is creating a VHD that is ready to be use in Azure. In order to prepare RHEL to be used in Azure you have to follow some specific steps which explains here. Note some important points before you start.

RHEL installation notes

  • The newer VHDX format is not supported in Azure. You can convert the disk to VHD format by using Hyper-V Manager or the convert-vhd PowerShell cmdlet.
  • VHDs must be created as "fixed"--dynamic VHDs are not supported.
  • When you're installing the Linux operating system, we recommend that you use standard partitions rather than Logical Volume Manager (LVM) (which is often the default for many installations). This will help you to avoid LVM name conflicts with cloned VMs, particularly if an OS disk ever needs to be attached to another VM for troubleshooting. You can use LVM or RAID on data disks if you prefer.
  • Do not configure a swap partition on the OS disk. You can configure the Linux agent to create a swap file on the temporary resource disk. More information about this is available in the steps below.
  • All of the VHDs must have sizes that are multiples of 1 MB.
  • When you use qemu-img to convert disk images to VHD format, note that there is a known bug in qemu-img versions 2.2.1 or later. This bug results in an improperly formatted VHD. The issue is intended to be fixed in an upcoming release of qemu-img. For now, we recommend that you use qemu-img version 2.2.0 or earlier.

In my case, I have downloaded the ISO and used Hyper-V to spin-up a virtual machine. There are detailed steps mentioned in the RedHat developer portal.

After creating the Virtual machine based out of the instructions from RedHat portal, next step was to prepare RHEL to be used in Azure. I had used RHEL 7.2 and I had to follow the instructions listed here.

Once you are done till here, you can shut down the virtual machine. In my case I was using the VHDX format, I had to convert it to VHD first to upload the OS disk to Azure.

Convert-VHD –Path E:\Hyper-V\rhlinux-dev.vazure loginhdx –DestinationPath E:\Hyper-V\rhlinux-dev.vhd –VHDType Fixed 

Above will create a VHD disk with Fixed size which is what we need in Azure. Next steps are working with Azure

Step 2: Create Storage Account and Upload the VHD to Azure

I used Azure CLI for most part of the remaining tasks.

//login to Azure, below CLI will give you a code and you can login in the web portal using that code which will authentication you in the CLI

azure login

//List out all of your subscription to set the one that you need to test these steps

azure account list

// In my case I have used my MSDN Azure Subscription

azure account set "Visual Studio Ultimate with MSDN"

// Its recommend to use the ARM model, below CLI will switch to ARM Mode

azure config mode arm

// Create a Resource Group by specifying the name and location

azure group create -n "dev-redhat-rg" -l "East US"

// Create storage account, I'm not providing all parameters in line instead I let the command to prompt

azure storage account create "devredhatstg01"

//You have to grab the storage account key for further steps, so list the keys, used the same resource group

azure storage account keys list devredhatstg01

//create a container

azure storage container create "rhlxvhdtemplate" -k "SEmner/2424jljadfasdfasdl+4VDplBJhw6LCS0rDYstM/chdYf3VyHkzRA==" -a "devredhatstg01"

//Upload the VHD, it took 2 hours for me to complete, for info below.

azure storage blob upload -f "E:\Hyper-V\rhlinux-dev.vhd" -b "rhlx-dev.vhd" -t page --container "rhlxvhdtemplate" -a "devredhatstg01" -k "SEmner/ZP7HIMukWI46WBC+82usasdfhl23kddlaYP34ouklj345l34jljl34k5j3lk5j+4VDplBJhw6LCS0rDYstM/chdYf3VyHkzRA=="

It took two hours to upload 25 GB VHD to Azure storage account. I think this experience will vary depends on your network bandwidth speed to Azure data center. I'm in Woodbridge, US and chosen East US as my Azure Storage location.

Step 3: Create a virtual machine based out of the custom VHD

Now, we are ready to create a virtual machine based out of the VHD we have it in Azure. I used ARM template and CLI to provision the VM using the custom image. You can get it from here. Once you are done you can see that VM is up and running. I had to create a NSG and create a SSH input rule for port 22 to enable SSH remotely.

azure group deployment create --template-uri "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-vm-from-user-image/azuredeploy.json" dev-rhel-vm-rg customVhdDeployment

Step 4: Test your Virtual Machine

I used Putty on my windows 10 machine to SSH and test the machine. You might need to register to your RHEL subscription if you have already unsubscribed part of RHEL preparation.