Create and Configure Azure Virtual Machines: Sizes, Images, Disks, Networking, Extensions and Connecting Securely

Microsoft Certified Azure Administrator Associate AZ 103 65 min min read Updated: Nov 17, 2026 Beginner
Create and Configure Azure Virtual Machines: Sizes, Images, Disks, Networking, Extensions and Connecting Securely
Beginner Topic 1 of 3

VM Building Blocks

PartNotes
ImageOS template from Marketplace or your own
SizevCPU, memory, disk and network limits
OS disk and data disksManaged disks
Network interface (NIC)Connects to a subnet, may have a public IP
Network security groupFirewall rules
Availability optionNone, zone, availability set or scale set

Choosing a Size

SeriesUse
BBurstable, low average CPU, dev/test
DGeneral purpose
EMemory optimized, databases
FCompute optimized
NGPU
LStorage optimized

Size names change by generation. Use az vm list-sizes -l centralindia -o table for the current list.

Create a Linux VM

bash az group create -n rg-vm -l centralindia az vm create -g rg-vm -n web01 --image Ubuntu2204 --size Standard_B2s \ --admin-username azureuser --generate-ssh-keys --public-ip-sku Standard \ --vnet-name vnet-vm --subnet default --nsg-rule SSH --zone 1 az vm list -d -g rg-vm -o table

Create a Windows VM

powershell $cred = Get-Credential New-AzVM -ResourceGroupName rg-vm -Name win01 -Location centralindia -Image Win2022Datacenter -Size Standard_B2s ` -Credential $cred -VirtualNetworkName vnet-vm -SubnetName default -PublicIpAddressName pip-win01 -OpenPorts 3389
Open ports Do not leave RDP (3389) or SSH (22) open to the whole internet. Use Azure Bastion, just-in-time access or a VPN.

Disks

DiskUse
Standard HDDBackup and rarely used data
Standard SSDLight production and dev/test
Premium SSD / SSD v2Production databases and apps
Ultra DiskVery high IOPS and low latency
bash az vm disk attach -g rg-vm --vm-name web01 --name data01 --new --size-gb 128 --sku Premium_LRS # inside the VM: partition, format and mount the new disk (lsblk, fdisk, mkfs, mount) or use Disk Management on Windows
  • Host caching: ReadOnly for data disks that are mostly read, None for write-heavy log disks
  • You can expand a disk (VM must be deallocated for some cases) but not shrink it

Extensions

bash az vm extension set -g rg-vm --vm-name web01 --publisher Microsoft.Azure.Extensions --name CustomScript \ --settings '{"commandToExecute":"sudo apt-get update && sudo apt-get install -y nginx"}'
  • Extensions install agents or run scripts after deployment (Custom Script, Azure Monitor Agent, Desired State, Disk Encryption)
  • cloud-init (Linux) and custom data run at first boot

Power States and Billing

StateCompute billed?
RunningYes
Stopped (inside OS)Yes, resources still allocated
Stopped (deallocated)No. Disks and static IPs still billed
bash az vm deallocate -g rg-vm -n web01 az vm start -g rg-vm -n web01 az vm resize -g rg-vm -n web01 --size Standard_D2s_v5
  • Resizing may restart the VM. If the size is not available on the host, deallocate first
  • Dynamic public IPs change after deallocation. Use static if needed

Connecting

  • Bastion: browser-based RDP/SSH over TLS, no public IP needed
  • JIT access opens ports for a short time (Defender for Cloud)
  • Serial console and Run command for troubleshooting
  • Redeploy moves a VM to a new host if connection fails

Practice

  1. Create a Linux VM and install nginx with the Custom Script extension
  2. Add and mount a data disk
  3. Deallocate and resize the VM
  4. Connect through Bastion instead of a public IP

Conclusion

A VM has an image, size, disks, NIC and NSG. Create it with portal, CLI or PowerShell, use extensions for setup, deallocate to stop compute billing and connect with Bastion or JIT for safety.

Quick Summary: building blocks; sizes; Linux and Windows; disks; extensions; billing; connecting.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators