Join Bhargav Shukla for an in-depth discussion in this video Create CentOS VM in Hyper-V, part of Microsoft Azure: Create a Linux Virtual Machine.
- [Instructor] There are multiple Linux distributions to choose from in Azure marketplace that I can deploy to my Azure subscription. I only need to create a custom image if available images do not meet my needs. To create a custom Linux image for Azure, I need to create a VM in Hyper-V. For a Linux VM, select from one of various Linux distributions Azure supports, including Red Hat Enterprise, Ubuntu, and CentOS.
While most steps to prepare each distribution for Azure are common, pay attention to steps for a given distribution, as some preparation steps are unique to each Linux distribution. If you plan to use Ubuntu, check the official Azure VHDs it publishes. It is best to use official Ubuntu images that are Azure-ready and customize further only if needed. For this course, I'm going to customize minimal installation of CentOS 7.
Let me show you how to create a VM in Hyper-V and install CentOS on the VM. I have downloaded CentOS ISO that I will be installing the CentOS from. I will start by creating a VM in Hyper-V. I'll start by creating a new virtual machine and click Next on the Before You Begin page. I will name the VM CentOS7 and click next. While CentOS 7 supports Generation 2 VMs in Hyper-V, since I am preparing the VM for use in Azure, I will select Generation 1 VM and click Next.
Default allocation of 1 gigabyte of memory is sufficient for the CentOS image that I'm going to customize. So I will click Next. On the networking page, I will select the virtual switch that the VM will be connected to. This will allow the VM to connect to the network as necessary. I'll click Next. Now I'll create a new 4 gigabyte virtual hard drive and store it in default location. This will allow me to keep the size of the hard drive to the minimum and it will help with the upload to Azure.
Next I will select Boot From CD/DVD Image and select downloaded CentOS 7 ISO file. Next I will verify the information on the summary page and click Finish to create the VM. Once the VM is created, I will connect to the VM console and start the VM. This starts the VM and boots from the CentOS ISO file. I will select the default option to start the installation and press Enter.
Once the installation starts, I am presented with language selection page, where I will accept the defaults and click Continue. On the installation summary page, I will select installation destination. Once presented with device selection, I will click Done to accept the default partition scheme. Now I will click Begin Installation, which will start the installation. While the installation continues, I will set the root password.
Here you can set any password you like. Ubuntu suggests if the password is weak or strong. If you select a weak password, it will require you to press Done twice. The password I have provided is strong. When I click Done, I will be returned to the installation screen. When the installation completes, I'll click Reboot to finalize the installation. I now have a working CentOS 7 VM.
I can now customize and prepare the VM for Azure. If you'd like to learn more about CentOS installation and configuration, check out the course Linux: Overview and Installation in our library.
- Installing Azure CLI
- Creating Virtual Network (VNet) and storage accounts
- Creating a custom Linux image
- Deploying a Linux virtual machine from Azure Marketplace
- Using VM Agent