Creating a Linux Virtual Machine in Azure
Tags: cloudcomputing, newbie, linux, azure
Published: 2024-04-15 14:07:25

Today I will be showing you how to setup a Linux Virtual Machine (VM) on Microsoft Azure. This guide is just for a basic setup and some. The Linux operating system of choice for this blog post will be Ubuntu.

Okay, time to begin.


## Prerequisite 


First thing login to your Microsoft Azure Portal by going to https://portal.azure.com.

If you do not have an azure account sign up and create an account for free with this link https://azure.microsoft.com/en-us/free/. Registration will require a phone number and a debit or credit card details to validate your account even for the free account. You have a choice between the free or pay as you go account.


**Note**: _Make sure the bank card you use for signing up allows international transactions. The free trial account provides $200 in Azure credits to be utilized within the first 30 days of sign-up, plus 12 months of selected free services (subject to change). After the initial 30 days, you will need to upgrade to a pay-as-you-go subscription._ 

Once you’ve Logged into your account you can begin.

## Creating Linux Virtual Machine 

**Step 1:** Search for **Virtual Machine** (VM) in the search bar at the top of your portal page and Select **Virtual Machines**.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qfqnszx7y190ct3v9ko5.png)


**Step 2:** Select **Create** and select **Azure Virtual Machine**. _(There is a create button at the centre of your portal and another towards the top left side of your screen both function similarly)_


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pwwu9hala4b357g7sq7u.png)



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uyu1hyolbfylz1kqdbwu.png)

**Step 3:** You are now in the **Create a Virtual Machine** page. We will be working primarily under the **Basics** tab.


**Step 4: Project details**
a.	**Subscription:** Choose your subscription. Here we will be using the default Azure subscription, if you have others, you can select another.

b.	**Resource group:** Select Create new and type a name and select **OK**.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/79cyxr82n0j3yko0hnny.png)


**Step 5: Instance details**

 a.	**Virtual machine name:** Give your VM a name and it should be unique throughout the Azure network.

b.	**Region:** Select a location you want your VM, from the dropdown menu. _[ A region is the geographical location with data centres that host services and infrastructures, with each operating independently and self-contained]_

c.	**Availability options:** we leave on the default **Availability zone**.

d.	**Availability zone:** Select the zone or zones you would like your VM to be located _[Each Region in Azure can consist of more than one Availability zone. Each zone are kilometres apart and independent of each other to minimize the impact of failures and disruptions. Multiple zones can be selected each having their own Virtual machine] _


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vggum116nt5e4mzgntbp.png)


e.	**Security type:** We leave on the default **Trusted launch virtual machines**.

f.	**Image:** Select from the dropdown menu a **Linux** image for this exercise I will be selecting **Ubuntu Server 22.04 LTS - x64 Gen 2(free services eligible)**


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rzwyxx3tbm1uo1k29hcg.png)

**Step 6: Administrator Account**
a.	**Authentication type:** There are two options to choose from **SSH public key** or **Password**. In this blog post we will be selecting Password.

b.	**Username:** Name your administrator account

c.	**Password:** type your password and confirm the password  


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uefhhrup3m3n422xvpxt.png)

**Step 7: Inbound port rules**
a.	**Public inbound ports:**  Select **Allow selected ports.**

b.	**Select inbound ports:** From the dropdown menu select **SSH (22)** if it's not selected by default.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9fpa602z33mzvza7ma6k.png)

c.	Click **Next: Disk >** at the bottom left of your portal.  


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m50kuj4d7ecux66jwybv.png)

**Step 8:** Once you click **Next: Disks>** you are moved to the **Disk **tab of the **Create Virtual Machine** service.       
a.	**OS disk type:** Select any disk type of your choosing. I will be selecting **Premium SSD**.  


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gc6xpdrl1183u4dwe7hq.png)

**Step 9:** For this guide we will be leaving the **Networking, Management, Monitoring, Advanced** and **Tag** pages on their default configuration. Click on **Review + Create** at the bottom left of your portal.

**Step 10:** At the **Review + Create** you should get a **Validation passed** at the top left of your screen. Review your settings and make any changes if required and select **Create**.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/obo7i6pviss6hrrp6rc8.png)

**Step 11:** Once you get **Your deployment is complete** click on **Go to resource**.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wvh8r6sz62vxd47b1m9i.png)


**Step 12:** Take note of your **Public IP address** before you click **Connect** and select **Connect** again.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j6tl15as2j8tyufijpfj.png)

**Step 13:** Open **Windows PowerShell** on your computer. For those new to PowerShell you can simply press the windows button on your keyboard and search for Windows PowerShell and click to open.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1iovuxp7s2ledryd1vf8.png)



a.	Type in this command **ssh username@ipaddress** and press enter. _**(username is your administrator account username and your public ip address)**_
 
b.	You will be asked **‘Are you sure you want to continue connecting (yes/no/[fingerprint])?’** type **Yes
**



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/84nzt780xr05m4lb897n.png)

c.	Enter your password. 

At this point if you delay in typing in your password your connection will be closed as seen in the picture highlighted below.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qr1u5xtddfiopruyu55s.png)

To resolve this 

**Step 14:** Go back to your Azure portal click on **Overview **and click the **Public IP address**. This takes you to the configuration page.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qj66t6qafuy10yz5acfw.png)

a.	Go to the **idle timeout (in minutes)**. Increase this time to 30 minutes either by using the slider or typing in the box.

b.	Click **Save **towards the top left



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/71wndxb5gtg6s6z35ps3.png)

c.	Go back to PowerShell and input command **ssh username@ipaddress** once again and press enter.

d.	Enter your password and press enter. _**(do not be alarmed when typing in your password and no characters or figures shows it is completely normal, just input the right password)**_

If all the steps were done correctly then the connection will be successful, and you will be logged into your Ubuntu Virtual Machine. 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nxntz7znq24b24i96kag.png)


Congrats on you have a Linux Virtual machine.