Lesson 2 of 5 Azure Compute Services

Understanding Azure Virtual Machines and Their Resources

This lesson explains Azure Virtual Machines, the image and size choices, the other Azure resources that a VM requires, and how VMs are billed.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe what Azure Virtual Machines provides.
  • Identify the required and optional resources for a virtual machine.
  • Explain how running, stopped and deallocated states affect billing.

What Azure Virtual Machines provides

With Azure Virtual Machines, you create VMs running Windows or Linux in minutes, with no hardware to buy, and pay only while they run. You have total control over the operating system and can run custom software. VMs are a good choice for testing and development, running applications in the cloud, extending an on-premises datacentre, lift-and-shift migration and disaster recovery for on-premises servers.

When creating a VM you choose an image, which is a template containing the operating system and sometimes preinstalled software, such as Windows Server 2025, Ubuntu Server or SQL Server on Windows; images come from Microsoft, from Azure Marketplace or from your own custom images. You also choose a size, which sets the number of virtual CPUs, the amount of memory and other capabilities. Sizes are grouped into families, such as general purpose, compute optimized, memory optimized, storage optimized and GPU, and a VM can be resized later.

Match the pairs

VM building blocks

Exam skills 2.2.2 · 2.2.3

Match each VM term with its meaning.

Log in to try this activity Interactive activities are free with an account.

Resources a virtual machine needs

A VM is not a single resource. When you create one, it needs several related resources, which the portal can create for you or which you can select if they already exist. The following table lists them.

ResourceRequiredPurpose
Size (compute)YesCPUs, memory and temporary storage for the VM
OS diskYesA managed disk that holds the operating system
Data disksNoExtra managed disks for applications and data
Virtual network and subnetYesThe private network the VM connects to
Network interface (NIC)YesConnects the VM to the subnet and holds its private IP address
Public IP addressNoAllows direct inbound connections from the internet
Network security group (NSG)NoFilters inbound and outbound traffic for the NIC or subnet

Disks are Azure managed disks, stored in Azure Storage and available as Standard HDD, Standard SSD, Premium SSD, Premium SSD v2 and Ultra Disk, which differ in performance and price. Each of these related resources is a separate resource with its own cost. Deleting a VM can leave its disks, NIC and public IP address behind unless you choose to delete them with it, and those leftovers continue to be billed.

The following diagram shows a virtual machine with its related resources.

The resources a virtual machine needs. The VM's size sets its CPUs and memory, and it needs a managed OS disk, a network interface that holds its private IP address, and a virtual network and subnet. Data disks, a public IP address and a network security group are optional. Each is a separate resource with its own cost, and deleting the VM can leave its disks, NIC and public IP address behind, still billed.
A VM is several resources, each with its own cost.
Sort into groups

Required or optional?

Exam skills 2.2.3

Decide which resources every VM needs.

Log in to try this activity Interactive activities are free with an account.

Running, stopping and billing

VM compute is billed per second while the VM is running. If you shut down the operating system from inside the VM, the VM is stopped but still allocated, and compute charges continue. If you stop it from the Azure portal, CLI or PowerShell, it is stopped (deallocated): the hardware is released and compute charges stop, although disks are still billed. Access to VMs is usually through Remote Desktop Protocol (RDP) for Windows or Secure Shell (SSH) for Linux, ideally through Azure Bastion or a VPN rather than an open public port.

Worked example

Unexpected charges

A tester deletes a test VM at the end of a project but notices a month later that the resource group still generates storage and networking charges. What is the most likely cause, and how could the tester have avoided it?

A VM depends on separate resources, including its managed disks, network interface and public IP address. If they were not deleted with the VM, they remain and the disks and public IP address continue to be billed. The tester could have selected the option to delete associated resources with the VM, or, because the VM was for a temporary project, created everything in its own resource group and deleted the whole resource group.

Check yourself

Does shutting down a VM from inside its operating system stop compute charges?

Show answer

No. The VM stays allocated. Stopping it from the portal, CLI or PowerShell deallocates it and stops compute charges.

Exam Tips

Remember for the exam

  • A VM needs a size, an image, an OS disk, a virtual network and subnet, and a NIC; public IP and NSG are optional.
  • Associated resources are separate and can keep incurring costs after the VM is deleted.
  • Stopped (deallocated) VMs do not incur compute charges; their disks are still billed.