Deploying an Azure Virtual Machine: A Comprehensive Tutorial

This tutorial will guide you through the process of deploying a virtual machine (VM) on Microsoft Azure using the Azure portal. We'll cover the essential steps from creating the VM to basic configuration.

Introduction to Azure VMs

Azure Virtual Machines (VMs) provide on-demand, scalable computing resources. They offer the flexibility of virtualization for a wide variety of computing workloads. You can deploy Windows and Linux VMs to run applications, host websites, and much more. Azure VMs are designed to be highly available and can be easily scaled up or down based on your needs.

In this tutorial, we will focus on the most common method: using the Azure portal, a web-based interface for managing Azure resources.

Prerequisites

Step-by-Step Deployment Guide

  1. Log in to the Azure Portal

    Open your web browser and navigate to https://portal.azure.com/. Log in with your Azure account credentials.

  2. Create a Virtual Machine

    In the Azure portal, search for "Virtual machines" in the search bar at the top and select it from the services list. Click the + Create button and then select Virtual machine.

    Azure Portal - Create VM Button

    Screenshot illustrating the 'Create Virtual machine' option.

  3. Configure Basic Settings

    On the "Create a virtual machine" page, you'll need to fill out several sections:

    • Subscription: Select your Azure subscription.
    • Resource group: A resource group is a logical container for your Azure resources. You can create a new one or select an existing one. Click Create new and provide a name (e.g., myVMResourceGroup).
    • Virtual machine name: Enter a unique name for your VM (e.g., myAzureVM).
    • Region: Choose the Azure region closest to your users or where you want your VM to reside.
    • Availability options: For this basic deployment, you can leave it as "No infrastructure redundancy required."
    • Security type: Standard security is usually sufficient for basic deployments.
    • Image: Select the operating system image for your VM. For example, you can choose "Windows Server 2022 Datacenter: Azure Edition" or a Linux distribution like "Ubuntu Server 20.04 LTS."
    • Size: Choose the VM size that matches your performance and cost requirements. For testing, a smaller size like Standard_B1s is often sufficient.
    • Administrator account:
      • Authentication type: For Windows, choose "Password." For Linux, you can choose "SSH public key" (recommended) or "Password."
      • Username: Enter an administrator username (e.g., azureuser).
      • Password: If using password authentication, set a strong password and confirm it.
    • Inbound port rules:
      • Public inbound ports: Select "Allow selected ports."
      • Select inbound ports: For a Windows VM, select "RDP (3389)." For a Linux VM, select "SSH (22)." This will allow you to connect to your VM remotely.
  4. Configure Disks

    In the "Disks" tab, you can configure the OS disk and add data disks. For this tutorial, the default settings are usually fine. You can choose the OS disk type (e.g., Premium SSD, Standard SSD, Standard HDD) based on performance and cost.

  5. Configure Networking

    The "Networking" tab allows you to configure virtual networks, subnets, public IP addresses, and network security groups (NSGs). By default, Azure will create a new virtual network, subnet, and public IP address for your VM. The NSG will automatically include the inbound port rules you selected earlier.

  6. Configure Management, Advanced, and Tags (Optional)

    These tabs offer additional configurations for monitoring, auto-shutdown, extensions, and resource organization. For a basic deployment, you can often skip these or accept the defaults.

  7. Review and Create

    Click the Review + create button. Azure will validate your configuration. Once the validation passes, review the summary of your VM settings. Click the Create button to start the deployment.

    Azure Portal - Review and Create Button

    Screenshot of the review and create stage.

  8. Deployment in Progress

    The deployment process may take a few minutes. You can monitor the progress in the Azure portal. Once completed, you will see a "Deployment succeeded" message.

Connecting to Your Azure VM

After the deployment is complete, navigate back to the "Virtual machines" service. Click on your newly created VM name to open its overview page.

For Windows VMs:

On the VM overview page, click the Connect button. Select "RDP" and download the RDP file. Open the file and connect using the administrator username and password you set during creation.

For Linux VMs:

On the VM overview page, you will find the public IP address of your VM. You can connect using an SSH client (like PuTTY on Windows or the built-in terminal on macOS/Linux) with the following command:

ssh azureuser@YOUR_VM_PUBLIC_IP_ADDRESS

If you used SSH key authentication, you might need to specify the path to your private key:

ssh -i /path/to/your/private/key azureuser@YOUR_VM_PUBLIC_IP_ADDRESS

Remember to replace azureuser with your chosen username and YOUR_VM_PUBLIC_IP_ADDRESS with the actual public IP address of your VM.

Next Steps