HOW TO CREATE A LINUX VIRTUAL MACHINE IN AZURE

HOW TO CREATE A LINUX VIRTUAL MACHINE IN AZURE

There are many reasons to create a Linux Virtual Machine (VM) in Azure; like hosting a web server, database, or many other uses for VMs. Creating a Linux virtual machine (VM) on the Azure portal is a detailed process that involves multiple steps and once created, the VM can be connected with a password-based authentication or via SSH public key authentication, enabling you to configure it for whatever workload you need.
In this comprehensive guide, I will walk you through each step using a public key authentication and ensure you clearly understand how to create a Linux VM on the Azure portal using Ubuntu Server.

We will also demonstrate how to prevent unexpected SSH disconnections due to idle sessions, it’s important to extend the idle timeout for your IP address to prevent unexpected logouts.

Before you start, ensure you have an active Azure subscription, if you don’t have one, Click here to create a free account.

Now that you have created your Azure subscription, sign in to the Azure portal using your e-mail and password to get started.

CREATE YOUR VIRTUAL MACHINE
a) On your Home Dashboard click on the Search bar and Search for
Virtual Machine

b) Click on Create and select the Azure Virtual Machine option

YOU WILL BE DIRECTED TO DIFFERENT TABS TO CONFIGURE YOUR VIRTUAL MACHINE

Basics Tab

In the Project Details Section, we have the Subscription and Resource Group
a)Subscription
To utilize Azure, a subscription to the platform is required. This subscription grants authorized access to a wide range of Azure products and services and the ability to organize resource groups effectively and manage billing. Additionally, Azure subscriptions offer a free trial and a flexible pay-as-you-go pricing model.

b)Resource Groups
Resource Groups are essential containers that house multiple Azure resources, such as virtual machines, app services, storage accounts, and databases. They offer crucial flexibility for managing the lifecycle of all services in one central location within the Azure cloud. With a resource group, you can confidently deploy, update, and delete these services simultaneously.

In the Instance Details Section

a) Enter a name in the Virtual machine name field.
b) Select a region closest to you in the Region field.

Regions refer to the geographic areas where Microsoft Azure has deployed its data centers, from which users can deploy their applications and services. Each region is made up of multiple data centers that are connected by a low-latency network, enabling users to access their resources quickly and reliably

C) Click on the drop-down to select your availability option and
availability Zone.

Availability zones are physically separated data centers within an Azure region. Each availability zone encompasses one or more data centers that function independently with their own power, cooling, and networking infrastructure. These zones are interconnected through high-speed, private fiber-optic networks. Therefore, if one zone experiences an outage, the others remain operational. At a minimum, three distinct availability zones are situated kilometers apart.

d) Click the drop-down menu to select your security type

e) In the Image field, click the dropdown menu and select any Ubuntu Server.

Ubuntu is a Linux Operating System. Images are utilized to install an operating system in a new virtual machine. An image may also contain one or more data disks. To view a range of operating systems available in the Marketplace, including the latest versions of various Linux distributions and Windows Server, click on “see all images”

f) In the size field, click the drop-down menu to select your size or click to see all sizes.

In the Administrator account section

a) Select the SSH Public Key authentication type.

SSH public key authentication relies on key pairs and cryptographic algorithms for secure remote access. Public key authentication offers stronger security and protection against various attacks, making it a preferred choice for secure remote connections, While Password-based authentication involves using a username and secret password to access a system as shown below.

However, for this tutorial, we will use SSH public key authentication.

b) Set up a unique username (Keep the username secure as we will require it later to log into our virtual machine
c) In the SSH public key source, Click the drop-down menu and select Generate new key pair
d) Create a key pair name

Inbound Port Rules Section

a) In this category, select SSH (22) as your inbound port to connect to the Linux server.

b) Click “Next: Disk>” to direct you to the disk page

DiskS Tab
a) Leave the OS Disk Size in the image default setting or select a preferred size from the drop-down menu.

b) Select Standard SSD or any other disk type of your choice in the OS disk type field. Leave other columns as default.

Leave networking, management, monitoring, and advanced tabs configurations as default. Skip to the Tag page.

Tag Tab
a) Give your tag a name and value
Tagging is a way to organize your Azure resources, resource groups, subscriptions, and management groups hierarchy for better filtering, monitoring, or querying a few scenarios. Each tag contains a name and a value pair.

Review the summary of your virtual machine configuration and click Next: Review + Create

In the Review + Create tab
a) Click the Review + Create tab and click on the Create button to begin the deployment process.

b) While the deployment is in process, a small window will pop up, click on the Download private key and create resource to generate a new key pair

c) Once the new key pair has been downloaded and the deployment process is completed, click on Go to Resource

CONNECT TO YOUR VIRTUAL MACHINE

a) Click on the connect button to SSH to your Virtual Machine

b) Keep your Admin username and public IP address secure as we will require them later to log into our virtual machine

c) Open PowerShell or CMD on your computer and input the command below
ssh -i (private key path) username@public IP address

d) To copy the private key pair, locate your downloaded private key in your computer, right-click on the file, and click properties.
Click the Security tab at the top of the window to copy the object name (private key path).

e) Input this command in your PowerShell terminal and click enter
ssh -i C:UsersJoshDesktopLinuxV_key.pem josh3k2@20.97.192.255

f) At this stage my connection timed out because of the default “idle time out” setting in the Azure portal. If you got this or ” connection closed”, the next thing is to go back to the Azure portal and locate your virtual machine.

g) On the overview page, click on your Public IP address

h) Click on the idle timeout cursor to increase the time to your desired value and click on save. In this case, I will increase it to 30 minutes.

I) Next, we go back to our Power Shell window and input our previous command again ssh -i (private key path) username@public IP address
Next, type yes to connect.

Congratulation!!! You have successfully connected to your Linux Virtual Machine

HOW TO DISSOCIATE YOUR IP ADDRESS
One method to reduce cost is disassociating your virtual machine from its IP address.

a) Locate your virtual machine and Click on the Public IP address associated with your virtual machine

b) Click on the overview

c) On the overview page, click on the Dissociate option located at the top of the page.

d) Click the Yes button to confirm the permanent dissociation of your public IP address from your virtual machine

HOW TO ASSOCIATE YOUR IP ADDRESS
a)To associate your IP, simply click on the Associate button.

b) A page will open up, click on the drop-down menu and choose the Resource type and Network interface. Click OK.

c) Your IP will be associated back to your virtual machine.

Leave a Reply

Your email address will not be published. Required fields are marked *