How to Create Linux Virtual Machine in Microsoft Azure with CLI

How to Create Linux Virtual Machine in Microsoft Azure with CLI
Getting your Trinity Audio player ready...

How to Create Linux Virtual Machine in Microsoft Azure with CLI

In this article, I will discuss virtual machines. What are virtual machines? Why they are important? Different types of virtual machines and how to create Linux Virtual Machine in Microsoft Azure with CLI Cloud Infrastructure. So let us explore first what is Virtual Machine.

What is Virtual Machine?

There was a time that may be approximately more than a decade issue organizations were facing an issue of underutilization of their IT infrastructure.

Surveys have shown that most organizations not even utilizing even 50% of their Infrastructure Capabilities.

Capacity Planning was much needed and organizations like Sun Microsystem (Now Oracle) taken the lead and shows the IT industry how they can utilize capacity planning to save infrastructure costs by producing LDOMS so-called Solaris Virtual Machines utilizing the full capacity of physical Solaris Servers. 

These were based on pure UNIX so the same was needed on Windows and Linux World also which was heavily cashed by VMware.

Virtual Machines becomes so popular with VMware and industries were heavily used to it to have their IT infrastructure minimal and using it to its maximum capacity.

With the advancement of technology Cloud Infrastructure became so popular in the last 5 years or more so all focus has been shifted to Cloud.

Infrastructure which gives freedom not to have their own data centers and keep paying recurring building electricity and maintenance costs.

This is helping two optimizations for the organization’s capacity optimization along with cost optimization.

To keep them alive in the enterprise sector VMware is trying hard to cope up with the competition between Cloud Infrastructure Services.

While Amazon Web Services are popularly known as AWS being the Industry Leader but Enterprize sector is heavily encashed by Microsoft.

This is due to their reach to the enterprise sector as almost all enterprise sector were already their clients especially desktops and servers.

So at present, whatever server being created in  Cloud Infrastructure is Virtual Machines only either it is Windows or It is Linux.

Our current topic how to create Linux virtual machine in Microsoft Azure cloud infrastructure.

Billing system in Microsoft Azure for Virtual Machines?

Please remember everything is getting build so be very specific in planning.

There are mainly two types of billing you can refer to the first one is PAYG which is Pay as you Go.

Billing happens based on availability and resource usage on an actual basis.

Another is Reserved Instances means you are creating virtual machines for long durations for example enterprise sector demands.

Organizations may have the requirement of virtual machines for many years so they can adapt to it and they can save costs of infrastructure.

Please remember even if you shut down your virtual machines it is still getting billed for storage.

So please make sure to decommission it if you do not need them.

There are still many things in it you can refer to Microsoft or other major vendors like AWS Google websites for their billing system how they bill and what are billing options they provide.

How to Create Linux Virtual Machine in Microsoft Azure using Azure CLI

High-Level Steps to create Linux Virtual Machine in Microsoft Azure Cloud Infrastructure are as below.

1. Install Azure CLI

2. Create a Resource Group

3. Create a Virtual Machine

Install Azure CLI in Linux 

Installing CLI requires python3 as a pre-requisite. You need to install and configure python3. Then you need to download Azure CLI RPM.

This is a one-time task you can decide and make one management server in your infrastructure. It will be easy for further deployments.

We have already shared about this so it is not worth sharing again. You can see here How to Install Azure CLI in Linux.

You will have permission to log in and work on CLI now. The only thing needed here your ID must be having proper privilege.

Create a Resource Group

First of all, you need to create a Resource Group. Please remember if you already have a Resource Group then this step can be ignored.

You can use the az group create command to create a resource group. Basically, Resource groups are containers in which you can have all the resources to manage them efficiently.

Resource Group is needed for organizing and managing them efficiently like Volume Group in LVM for efficient volume management or Disk Groups in VxVM for managing file systems efficiently.

So if it already exists you can use that instead of creating new. As per best practices to have various resource groups based on requirements for instance one for PROD one for DEV one for QA.

Even you have the opportunity to create if you have to segregate and still not present.

You can check resource group using the az group list command which will also show your subscription details.

# az group list 

This will display all the resource groups under 
your azure subscription. Some time this list may
be too long based on your azure usages.       

# az group create --name <RG> --location <DC>
#az group create --name myRG --location <EUS> 
--tags "Department=Sales" "Env=Development"
RG stands for Resource Group Name which
you can decide based on your organization
naming convention if any.
DC stands for Azure data center where 
you have plan to  create virtual machine.
Tagging Department Environment you can use
for their identification for the purpose of
billings which is not mandatory. 

Create a Virtual Machine

Once you either created a resource group or you already have an existing resource group now you can create the virtual machine.

To create a linux virtual machine az vm create command can be used. –generate-ssh-keys option is used to automatically generate SSH keys and save them.

–ssh-key-value parameter specifies which set of keys to use in creating vm.

This may take few minutes for the virtual machine to be launched.

# az vm create --resource-group myRG 
--name AZNIX01  --image RHEL7  --admin
-username azureuser  --generate-ssh-keys

That`s it about how to create linux virtual machine in Microsoft Azure with CLI.


This is just a good reference point for how to create vm in Microsoft Azure using CLI.

There may be some associated requirements like you need to have a storage account and network already configured.