What is a Virtual Machine in Azure? Explore Types & Uses of Virtual Machine

A virtual machine (VM) in Azure is an on-demand, scalable computing resource that emulates a physical computer, running an operating system and applications just like a physical server would — without you needing to own or maintain hardware.

How Azure VMs Work

Azure VMs run on top of Microsoft's physical infrastructure, using virtualization to let multiple VMs share the same physical hardware while remaining isolated from each other.

Types of Azure VM Series

  • General Purpose (e.g., D-series) — balanced CPU-to-memory ratio, suited for most everyday workloads
  • Compute Optimized (e.g., F-series) — high CPU-to-memory ratio, good for batch processing and application servers
  • Memory Optimized (e.g., E-series) — high memory-to-CPU ratio, suited for relational databases and in-memory analytics
  • Storage Optimized (e.g., L-series) — high disk throughput, ideal for big data and NoSQL databases
  • GPU (e.g., N-series) — designed for graphics rendering, AI, and machine learning workloads

Common Use Cases for Azure VMs

  • Hosting web applications and APIs that need full control over the operating system
  • Running legacy applications that can't easily be migrated to managed services
  • Development and testing environments that need to be spun up and torn down quickly
  • Running specialized workloads like databases, machine learning training, or high-performance computing

Basic Pricing Considerations

Azure VM cost typically depends on:
- VM size (vCPUs and memory)
- Region
- Operating system license
- Storage type and size
- Pricing model (Pay-as-you-go, Reserved Instances, Spot VMs)
Choosing the right VM series for your workload has a big impact on both performance and cost — it's worth benchmarking your actual resource usage before committing to a larger, more expensive size.

Ready to master Microsoft Azure?

Join Microsoft Azure Training Course at Uncodemy and learn with hands-on projects and mentor support.

Explore the Course

Creating a VM From the Command Line

The portal is good for learning, but the Azure CLI makes the steps repeatable. This example creates a small Linux VM without a public IP address, which is a safer starting point.

az group create --name demo-rg --location centralindia

az vm create \
  --resource-group demo-rg \
  --name web01 \
  --image Ubuntu2204 \
  --size Standard_B2s \
  --admin-username azureuser \
  --generate-ssh-keys \
  --public-ip-address ""

az vm list-sizes --location centralindia --output table   # see sizes offered in a region

Creating a VM also creates related resources: a network interface, an OS disk, and a virtual network and network security group if you did not specify existing ones. Deleting only the VM can leave these behind, so clean up the whole resource group when you finish a test.

Reading a VM Size Name

Size names look cryptic but follow a pattern. Take Standard_D4s_v5:

  • D is the family, here general purpose.
  • 4 is the number of vCPUs.
  • s means the size supports premium SSD storage.
  • v5 is the hardware generation; newer generations usually give better performance.

Other letters you may see include a for AMD processors, d for a local temporary disk and p for Arm-based processors.

Disks, Availability and Scaling

Managed disks come in several performance types, from Standard HDD for backups and rarely used data, through Standard SSD, to Premium SSD and Ultra Disk for demanding databases. Remember that the temporary disk, if present, is wiped when the VM moves to another host, so never store important data on it.

OptionProtects against
Availability setFailure or maintenance of a single rack or host group in a data centre
Availability zonesLoss of an entire data centre within a region
Virtual Machine Scale SetsOverload, by adding or removing identical VMs automatically

Check the Azure documentation for the current uptime commitment of each option and which regions support zones.

Running VMs Safely and Sensibly

  • Do not open SSH or RDP to the whole internet. Use Azure Bastion or just-in-time access from Microsoft Defender for Cloud.
  • Apply network security group rules that allow only the ports the workload needs.
  • Enable Azure Backup and plan OS patching, for example with Azure Update Manager.
  • Shutting down from inside the OS can leave compute billing running. Use az vm deallocate or the portal's Stop button to release compute; disks are still charged.
  • Tag resources with owner and environment so forgotten test machines are easy to find.

VM or Something Else?

Choose a VM when you need full control of the operating system, special drivers or software that cannot run elsewhere. If you only need to run a web app or API, App Service or Azure Container Apps remove patching work. For short event-driven jobs, Azure Functions is often simpler still.