Azure Documentation

Deploying Virtual Machines on Azure

This guide provides comprehensive steps and best practices for deploying Azure Virtual Machines (VMs) to meet your computing needs. Azure VMs offer scalable, on-demand computing resources that you can deploy and manage as easily as physical servers.

1. Prerequisites

Before you begin, ensure you have the following:

  • An Azure subscription. If you don't have one, create a free account.
  • Permissions to create resources within your subscription.

2. Deployment Methods

You can deploy Azure VMs using various methods:

  • Azure Portal: A user-friendly graphical interface for creating and managing resources.
  • Azure CLI: A command-line tool for managing Azure resources.
  • Azure PowerShell: Another command-line tool for managing Azure resources.
  • Azure Resource Manager (ARM) Templates: Declarative templates to deploy your infrastructure as code.

This documentation will primarily focus on the Azure Portal for ease of use, with references to CLI commands.

3. Deploying a VM using the Azure Portal

Follow these steps to deploy a VM:

  1. Sign in to the Azure Portal: Go to portal.azure.com and sign in with your Azure account.
  2. Create a resource: Click the "Create a resource" button (the plus icon in the top-left corner).
  3. Search for Virtual Machine: In the search bar, type "Virtual machine" and select "Virtual machine" from the results.
  4. Click Create: On the Virtual machine page, click the "Create" button.
  5. Basics Tab:
    • Subscription: Select your Azure subscription.
    • Resource group: Choose an existing resource group or create a new one. A resource group is a logical container for your Azure resources.
    • Virtual machine name: Enter a unique name for your VM.
    • Region: Select the Azure region where you want to deploy your VM.
    • Availability options: Choose your desired availability options (e.g., Availability Zone, Availability Set).
    • Security type: Select a security type (Standard, Trusted launch, Confidential).
    • Image: Select an operating system image (e.g., Windows Server, Ubuntu Server).
    • Size: Choose a VM size based on your performance and cost requirements.
    • Administrator account:
      • Authentication type: Select SSH public key or Password.
      • Username: Enter a username for the administrator.
      • Password/SSH public key: Provide your credentials.
    • Inbound port rules: Select public inbound ports to allow (e.g., RDP for Windows, SSH for Linux).
  6. Disks Tab: Configure your VM's storage. You can choose the OS disk type (e.g., Premium SSD, Standard SSD, Standard HDD) and add data disks if needed.
  7. Networking Tab: Configure the virtual network, subnet, public IP address, and network security group (NSG) for your VM. You can create new ones or use existing resources.
  8. Management, Advanced, Tags Tabs: Review and configure other settings such as monitoring, auto-shutdown, extensions, and tags as per your requirements.
  9. Review + create: Once all configurations are complete, click "Review + create". Azure will validate your settings.
  10. Create: If validation passes, click "Create" to start the deployment.
Tip: For repeatable deployments, consider using ARM templates or Bicep. You can generate templates from existing resources in the Azure portal.

4. Deploying a VM using Azure CLI

Here's a basic example of deploying a Linux VM using Azure CLI:

az vm create \
  --resource-group MyResourceGroup \
  --name MyVM \
  --image UbuntuLTS \
  --admin-username azureuser \
  --generate-ssh-keys

This command creates a VM named MyVM in the MyResourceGroup using the latest Ubuntu LTS image and generates an SSH key pair for authentication.

For Windows VMs, you would typically use a password:

az vm create \
  --resource-group MyResourceGroup \
  --name MyWinVM \
  --image Win2019Datacenter \
  --admin-username azureuser \
  --admin-password YourSecurePassword123!

Note: Replace MyResourceGroup, MyVM, MyWinVM, and credentials with your desired values.

5. Connecting to your VM

After deployment, you can connect to your VM:

  • Linux VMs: Use SSH. You'll need the VM's public IP address.
    ssh azureuser@
  • Windows VMs: Use Remote Desktop Protocol (RDP). You can download the RDP file from the Azure portal.