Overview
Azure Virtual Machines (VMs) provide on-demand, scalable computing resources with flexible configurations and operating system choices. Use VMs to run applications, host services, and develop/testing environments.
VMs integrate with the broader Azure ecosystem, offering features like managed disks, high availability sets, and auto-scaling.
Key Features
- Custom VM Sizes: Choose from a broad catalog of sizes optimized for compute, memory, storage, and GPU workloads.
- Operating System Support: Windows Server, Linux distributions, and custom images.
- High Availability: Availability Sets, Zones, and Managed Disks for resiliency.
- Scale Sets: Automatically increase or decrease VM count based on metrics.
- Security: Azure Security Center integration, encrypted disks, and network security groups.
Pricing & Billing
VM pricing is based on selected size, OS, region, and usage type (pay-as-you-go, Reserved Instances, Spot VMs). View the pricing calculator for detailed estimates.
az vm list-skus --location eastus --output table
Quick Start
Deploy a Linux VM using Azure CLI:
# Create a resource group
az group create --name MyResourceGroup --location eastus
# Create a virtual network and subnet
az network vnet create \
--resource-group MyResourceGroup \
--name MyVnet \
--subnet-name MySubnet
# Create a public IP address
az network public-ip create \
--resource-group MyResourceGroup \
--name MyPublicIP
# Create a network security group with SSH rule
az network nsg create \
--resource-group MyResourceGroup \
--name MyNSG
az network nsg rule create \
--resource-group MyResourceGroup \
--nsg-name MyNSG \
--name AllowSSH \
--protocol tcp \
--priority 1000 \
--destination-port-range 22 \
--access Allow
# Create a network interface
az network nic create \
--resource-group MyResourceGroup \
--vnet-name MyVnet \
--subnet MySubnet \
--network-security-group MyNSG \
--public-ip-address MyPublicIP \
--name MyNic
# Create the VM
az vm create \
--resource-group MyResourceGroup \
--name MyLinuxVM \
--image UbuntuLTS \
--admin-username azureuser \
--generate-ssh-keys \
--nics MyNic
Best Practices
- Use Managed Disks for better performance and reliability.
- Group VMs into Availability Sets or Zones to avoid single points of failure.
- Employ Azure Backup and Disk Snapshot for data protection.
- Leverage Azure Monitor and Log Analytics for health and performance insights.
- Consider Spot VMs for non-critical workloads to reduce costs.
Frequently Asked Questions
- Can I resize a running VM?
- Yes, Azure supports resizing VMs without data loss. Some size changes may require a restart.
- How do I secure SSH access?
- Use network security groups, Azure Bastion, or just-in-time (JIT) access for enhanced security.
- What is the difference between a VM and a VM Scale Set?
- A VM Scale Set provides automatic scaling and management of a group of identical VMs.