Understanding Virtual Machines

A virtual machine (VM) is a software-based emulation of a physical computer. Instead of occupying desk space, it resides in the cloud, offering immense flexibility and scalability. Consider a banking application: a bank could host it on its own servers, incurring significant costs for hardware, cooling, and maintenance. Alternatively, it can leverage Infrastructure as a Service (IaaS) providers like Microsoft Azure. This allows them to deploy and manage a VM with full control, eliminating the operational overhead of physical hardware. This article provides a comprehensive, step-by-step guide for beginners to create their own Linux VM on Microsoft Azure.

Step 1: Access the Azure Portal

The first step in creating your Linux VM is to access the Microsoft Azure portal. Navigate to portal.azure.com in your web browser and log in using your Azure account credentials. If you do not have an Azure account, you will need to sign up for one. Azure offers a free trial for new users, which can be a great way to get started.

Azure Portal login screen prompting user credentials

Step 2: Initiate VM Creation

Once logged into the Azure portal, you need to initiate the virtual machine creation process. Click on the "Create a resource" button, typically found in the top-left corner of the portal. From the "Marketplace" search bar, type "Virtual machine" and select it from the results. Then, click the "Create" button to begin configuring your new VM.

Step 3: Configure Basic VM Settings

This section involves setting up the fundamental parameters for your virtual machine. You'll need to provide the following details:

  • Subscription: Choose the Azure subscription under which the VM will be provisioned.
  • Resource group: A resource group is a logical container for Azure resources. You can select an existing one or create a new one by clicking "Create new". Give it a descriptive name, like "LinuxVM-RG".
  • Virtual machine name: Assign a unique and descriptive name to your VM, for instance, "MyLinuxVM".
  • Region: Select the Azure region where you want to deploy your VM. Choose a region geographically close to you or your users for lower latency.
  • Availability options: For basic setups, "No infrastructure redundancy required" is sufficient. For production workloads, consider availability zones or sets.
  • Security type: Standard security is generally adequate for beginner setups.
  • Image: This is crucial. Select your desired Linux distribution. Common choices include Ubuntu Server (LTS versions are recommended for stability), Red Hat Enterprise Linux, or CentOS. For this guide, we'll assume Ubuntu Server 22.04 LTS.
  • VM architecture: x64 is the standard for most modern VMs.
  • Size: Choose the VM size based on your performance needs and budget. Sizes like "Standard_B1s" (Burstable) are cost-effective for learning and development.
  • Authentication type: You have two primary options:
    • SSH public key: This is the more secure and recommended method. You'll generate an SSH key pair and provide the public key here.
    • Password: A simpler option for beginners, but less secure. You'll set a username and a strong password.
  • Username: If using password authentication, set a username (e.g., "azureuser"). If using SSH keys, this will be the user associated with the key.
  • Password/SSH public key: Provide the necessary credentials based on your chosen authentication type.
Azure VM basic configuration screen with essential fields highlighted

Step 4: Configure Disks

In the "Disks" tab, you can configure the storage for your VM. Azure offers different disk types:

  • OS disk type:
    • Standard HDD: Lowest cost, suitable for development/test workloads where performance is not critical.
    • Standard SSD: Balanced cost and performance, good for most general-purpose workloads.
    • Premium SSD: High performance, low latency, ideal for production workloads requiring fast I/O.
  • Data disks: You can attach additional disks for storing data separately from the OS. For a basic setup, this is optional.

For beginners, a Standard SSD for the OS disk offers a good balance of cost and performance.

Step 5: Configure Networking

The "Networking" tab allows you to set up the network interface for your VM. Key settings include:

  • Virtual network: A private network in Azure. You can use an existing one or let Azure create a new one.
  • Subnet: A range of IP addresses within your virtual network.
  • Public IP address: Required to connect to your VM from the internet. Azure can create a new one for you.
  • NIC network security group: This acts as a firewall for your VM. For basic SSH access, you'll need to ensure port 22 (SSH) is open. The default settings often include this.

Ensure that inbound port 22 is open to allow SSH connections.

Step 6: Advanced Settings and Review

The "Advanced" tab contains options for extensions, management, and monitoring. For a beginner's setup, you can generally leave these at their defaults. The "Tags" tab allows you to apply metadata to your VM for organization and billing purposes.

Finally, navigate to the "Review + create" tab. Azure will validate your configuration. If validation passes, you will see a summary of your VM settings. Review all details carefully. Once satisfied, click the "Create" button.

Step 7: Connect to Your Linux VM

After the deployment is complete (this may take a few minutes), you can connect to your VM. Navigate to your newly created virtual machine resource in the Azure portal. You will find the public IP address listed on the VM's overview page. Open your terminal or SSH client and use the following command:

ssh your_username@your_public_ip_address

If you used password authentication, you will be prompted for your password. If you used SSH key authentication, your client should use your private key automatically. You are now connected to your Linux VM on Azure.

Step 8: Post-Deployment Tasks

Once connected, it's good practice to:

  • Update your system: Run sudo apt update && sudo apt upgrade -y (for Ubuntu/Debian) or the equivalent for your distribution to install the latest security patches and software updates.
  • Configure firewall: Set up `ufw` (Uncomplicated Firewall) for enhanced security.
  • Install necessary software: Install any applications or services you intend to run on your VM.

This process provides a foundational understanding of deploying a Linux VM on Azure, enabling further exploration of cloud computing capabilities.