Azure Documentation

Create a Virtual Machine in Azure

This guide walks you through the process of creating a virtual machine (VM) in Azure. Azure VMs provide on-demand, scalable computing resources. You can create a VM using the Azure portal, Azure CLI, PowerShell, or ARM templates.

Using the Azure Portal

The Azure portal offers a user-friendly graphical interface for creating VMs.

  1. Sign in to the Azure portal:

    Go to portal.azure.com and sign in with your Azure account.

  2. Navigate to Virtual machines:

    In the Azure portal, search for "Virtual machines" and select it from the services list.

  3. Create a new VM:

    Click on the + Create button and select Virtual machine.

  4. Configure basic settings:
    • 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 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 the desired availability zone or set.
    • Security type: Select the security level for your VM.
    • Image: Select an operating system image (e.g., Windows Server, Ubuntu Server).
    • Size: Choose a VM size that meets your performance and cost requirements.
    • Administrator account:
      • Authentication type: Choose between SSH public key (recommended for Linux) or Password.
      • Username: Enter the administrator username.
      • Password/SSH public key: Provide the corresponding credentials.
    • Inbound port rules: Configure which network ports should be open to inbound traffic. For example, allow RDP (3389) for Windows or SSH (22) for Linux.
  5. Configure disks:

    Choose the OS disk type (e.g., Standard HDD, Standard SSD, Premium SSD) and configure data disks if needed.

  6. Configure networking:

    Set up your virtual network, subnet, public IP address, and network security group (NSG).

  7. Review and create:

    Review all your settings. If everything looks correct, click Create.

Tip: You can also create VMs programmatically using Azure CLI or PowerShell for automation and scripting purposes.

Using Azure CLI

The Azure Command-Line Interface (CLI) is a powerful tool for managing Azure resources from your terminal.

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

This command creates a Linux VM named myVM in the MyResourceGroup with an Ubuntu LTS image and generates SSH keys for authentication.

Key Concepts for VM Creation:

  • Resource Group: A container that holds related Azure resources for a solution.
  • VM Size: Determines the CPU, memory, and storage capacity of your VM.
  • Image: The operating system template for your VM.
  • Virtual Network (VNet): A virtual representation of your own network in Azure.
  • Network Security Group (NSG): Acts as a virtual firewall for your VM.

For more detailed information and advanced configuration options, please refer to the official Azure documentation on virtual machine creation.