Dev.to WebDev 🛠 Dev 👁 0 📖 6 min read

How to Create a Linux Virtual Machine in Microsoft Azure: A Step-by-Step Guide

Introduction Cloud computing has become an important part of modern technology, allowing individuals and organizations to create and manage computing resources over the internet. One of the services that makes this pos

How to Create a Linux Virtual Machine in Microsoft Azure: A Step-by-Step Guide

Introduction

Cloud computing has become an important part of modern technology, allowing individuals and organizations to create and manage computing resources over the internet. One of the services that makes this possible is Microsoft Azure, which allows users to create virtual machines running different operating systems, including Windows and Linux.

In my previous practical exercise, I created a Windows Virtual Machine on Microsoft Azure. After completing that exercise, I decided to explore how to create a Linux Virtual Machine as well.

In this article, I will walk you through the steps I followed to create a Linux Virtual Machine on Microsoft Azure. I will cover the configuration process, how to connect to the virtual machine, and how to perform basic Linux commands. This guide is intended for beginners who want to gain practical experience with cloud computing and virtual machines.

What Is a Linux Virtual Machine?

A Linux Virtual Machine (VM) is a virtual computer that runs a Linux operating system on a physical computer or a cloud platform. It behaves like a regular computer, with its own operating system, memory, storage, and processing resources.

Microsoft Azure allows users to create Linux Virtual Machines in the cloud without needing to install Linux directly on their personal computers. This makes it possible to practise Linux commands, host websites, install software, and learn about server administration remotely.

For this practical exercise, I used Microsoft Azure to create a Linux Virtual Machine running Ubuntu. This helped me understand how Linux servers can be deployed and managed in a cloud environment.

Prerequisites

Before creating a Linux Virtual Machine on Microsoft Azure, there are a few things you need to have in place:

  • A Microsoft Azure account: You need an account to access the Azure Portal and create virtual machines.
  • A stable internet connection: This allows you to access the Azure Portal and manage your virtual machine.
  • Basic computer knowledge: Familiarity with using a web browser and navigating websites will be helpful.
  • A Linux operating system image: For this practical exercise, I used Ubuntu as the operating system for my virtual machine.

Once these requirements are in place, you can proceed to the Azure Portal and begin creating your Linux Virtual Machine.

Step 1: Logging in to the Microsoft Azure Portal

The first step in creating a Linux Virtual Machine is to log in to the Microsoft Azure Portal.

  1. Open your web browser.

  2. Visit the Microsoft Azure Portal.

  3. Sign in using your Microsoft account credentials.

  4. Once you have successfully signed in, the Azure Portal dashboard will appear.

login portal

Step 2: Searching for Virtual Machines

After logging in to the Microsoft Azure Portal, the next step is to locate the Virtual Machines service.

On the Azure Portal homepage, locate the search bar at the top of the page.

Type Virtual Machines into the search bar.

Select Virtual Machines from the search results.

The Virtual Machines page will open, where you can view and manage your existing virtual machines and create new ones.
From this page, you can begin the process of deploying a Linux Virtual Machine.

Searching for Virtual Machines in the Microsoft Azure Portal

Step 3: Creating the Linux Virtual Machine

After opening the Virtual Machines page in the Azure Portal, the next step is to begin creating a new virtual machine.

On the Virtual Machines page, click Create.

Select Azure virtual machine from the available options.

The Create a virtual machine page will open.

This page contains several configuration settings that you need to complete before deploying your Linux virtual machine.

Creating a Linux Virtual Machine in the Microsoft Azure Portal.

Step 4: Configuring the Linux Virtual Machine

The Azure Portal provides several options that allow users to customize their virtual machines based on their needs.

The following settings need to be configured:

Subscription: Select the Azure subscription you want to use.

Resource group: Select an existing resource group or create a new one to organize your Azure resources.

Virtual machine name: Enter a name for your virtual machine.

Region: Select the Azure region where you want the virtual machine to be deployed.

Image: Choose the Linux operating system you want to install. For this practical exercise, I used Ubuntu.

Size: Select a virtual machine size based on the processing power and memory you need.

After entering the required details, review the configuration to ensure that the selected options meet your requirements.

Configuring the settings for an Ubuntu Linux Virtual Machine in Microsoft Azure.

Configuring the settings for an Ubuntu Linux Virtual Machine in Microsoft Azure part 2

Step 5: Configuring Authentication and Networking

After configuring the basic settings, the next step is to set up authentication and networking for the Linux Virtual Machine.

  1. Configure the Administrator Account

Azure requires an administrator username and an authentication method for accessing the Linux virtual machine.

Depending on the options available, you can use an SSH public key or a password for authentication. SSH key-based authentication is generally recommended because it provides a secure way to connect to a Linux server.

For this practical exercise, I configured the authentication settings required to access my virtual machine.

  1. Configure Network Settings

Networking determines how the virtual machine communicates with other resources and how users can connect to it.

During configuration, review the network interface, virtual network, subnet, and public IP settings. If you intend to connect remotely using SSH, ensure that TCP port 22 is permitted only from trusted sources where possible.

After reviewing the authentication and networking settings, proceed to the next stage of the virtual machine creation process.

Configuring the administrator account for the Linux Virtual Machine in Microsoft Azure.

Configuring inbound port rules for SSH access to the Linux Virtual Machine in Microsoft Azure.

Step 6: Reviewing and Creating the Linux Virtual Machine

After configuring the administrator account and networking settings, the next step is to review the virtual machine configuration before deployment.

Click Review + create at the bottom of the Azure Portal page.

Azure will validate the configuration to check whether the required settings are correct.

If validation succeeds, review the configuration details.

Click Create to begin deploying the Linux Virtual Machine.

Wait for the deployment process to complete.

Once the deployment is successful, Azure will display a confirmation message. You can then open the deployed virtual machine to view its details and connection information.

Reviewing the configuration and deploying a Linux Virtual Machine in Microsoft Azure.

Step 7: Connecting to the Linux Virtual Machine Using SSH

After the deployment was completed successfully, the next step was to connect to the Linux Virtual Machine.

Secure Shell (SSH) is a network protocol that allows users to securely access and manage a remote computer through a command-line interface.

To connect to my Linux Virtual Machine, I followed these steps:

Open the Virtual Machines page in the Microsoft Azure Portal.

Select the Linux Virtual Machine I created.

Locate the connection details, including the public IP address.

Open a terminal on my computer.

Use the appropriate SSH command to connect to the virtual machine.

Replace both placeholders with your VM's administrator username and public IP address. If you used an SSH private key, you may need the -i option and the path to that key.
Azure's official instructions explain that the username, public IP address, authentication method, and SSH network access must match your VM configuration.

Connecting to an Ubuntu Linux Virtual Machine on Microsoft Azure using SSH.

Step 8: Updating Linux and Installing NGINX

After connecting to the Linux Virtual Machine, the next step is to update the system and install the software needed for the practical exercise.

Ubuntu uses the APT package manager to install, update, and manage software packages.

  1. Update the Package List

First, I used the following command to update the package list:

sudo apt update

This command retrieves information about available packages from the configured software repositories.

  1. Upgrade Installed Packages

To upgrade installed packages when updates are available, run:

sudo apt upgrade

Review the prompt and confirm the upgrade if required.

  1. Install NGINX

NGINX is a web server that can be used to serve web pages and web applications.

To install NGINX on Ubuntu, run:

sudo apt install nginx

If prompted to continue, type Y and press Enter.

  1. Verify the Installation

After the installation, check whether the NGINX service is running:

sudo systemctl status nginx

If the service is active, NGINX is running on the virtual machine.

Updating Ubuntu packages

Installing the NGINX web server on an Ubuntu Linux Virtual Machine in Microsoft Azure.

Conclusion

Creating a Linux Virtual Machine on Microsoft Azure was a valuable hands-on learning experience for me. Through this practical exercise, I learned how to configure a virtual machine, select Ubuntu as the operating system, review networking and authentication settings, and access a Linux environment in the cloud.

I also explored basic Linux commands and the process of installing software using the APT package manager. These skills are useful for anyone interested in cloud computing, Linux system administration, and DevOps.

This exercise has encouraged me to continue learning about cloud technologies and practising more Linux commands. I hope this guide helps other beginners who want to create their first Linux Virtual Machine on Microsoft Azure.

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.