Lab 09 – VM Availability & Scaling

Objectives

Prerequisites

Estimated time

40 minutes


Part 1 – Resource group and network

  1. Search for Resource groups > Create. Name: rg-az104-lab09,

region: East US. Review + create > Create.

  1. Search for Virtual networks > Create. Resource group:

rg-az104-lab09, Name: vnet-lab09, Address space: 10.40.0.0/16.

Subnets tab: subnet-vms with range 10.40.1.0/24. Create.

Part 2 – Availability Set

important

An Availability Set must be specified at VM creation time. You cannot add an existing VM to an Availability Set.

  1. Search for Availability sets > Create. Resource group:

rg-az104-lab09, Name: avset-lab09,

Fault domains: 2, Update domains: 5. Create.

  1. Create two Linux VMs in this set:

- Virtual machines > Create > Basics: vm-av1, image Ubuntu

22.04 LTS, size StandardB1s, vnet-lab09/subnet-vms. Advanced

tab: set Availability set to avset-lab09. Create.

- Repeat for vm-av2.

  1. Both VMs are now automatically distributed across fault/update domains for

maintenance window and power outage protection within the same datacenter.

Part 3 – Availability Zones

  1. Create two more Linux VMs, each in a different availability zone:

- Virtual machines > Create > Basics: vm-zone1, image Ubuntu

22.04 LTS, size StandardB1s, vnet-lab09/subnet-vms. Advanced

tab: Availability zone = Zone 1. Create.

- Repeat for vm-zone2, setting zone to Zone 2.

📝

note

VMs cannot be in both an Availability Set and an Availability Zone —

they're mutually exclusive. Not all regions/sizes support zones.

Part 4 – Virtual Machine Scale Set

  1. Search for Virtual machine scale sets > Create.
  2. Basics tab:

- Resource group: rg-az104-lab09

- Name: vmss-lab09

- Region: East US

- Image: Ubuntu Server 22.04 LTS

- Size: Standard_B1s

- Initial instance count: 2

- Username: azureuser

- SSH public key: Generate new key pair or use existing

  1. Networking tab: Virtual network: vnet-lab09, Subnet:

subnet-vms, Public IP per instance: disabled (or keep default),

Load balancer: create new (e.g., lb-vmss09).

  1. Scaling tab: Initial instance count: 2.
  2. Management tab: Upgrade policy: Automatic.
  3. Review + create > Create.

Part 5 – Autoscale rules

ℹ️

tip

Set autoscale thresholds conservatively (e.g., 70% CPU to scale out, 30% to scale in) to avoid rapid scaling in/out fluctuations.

  1. Go to vmss-lab09 > Scaling (under Settings) > Configure

autoscale (or go to Monitor > Autoscale settings for the VMSS

resource).

  1. Set Minimum number of instances: 2, Maximum: 5, Default: 2.
  2. Create a rule: Scale out when CPU > 70%

- Metric: CPU Percentage

- Operator: Greater than

- Threshold: 70

- Duration: 5 minutes

- Action: Increase instance count by 1

  1. Create another rule: Scale in when CPU < 30%

- Metric: CPU Percentage

- Operator: Less than

- Threshold: 30

- Duration: 5 minutes

- Action: Decrease instance count by 1

  1. Save.

Part 6 – Manual scale & instance management

  1. Go to vmss-lab09 > Scaling > set Custom autoscale to Off

(to control manually), then set Instance count to 3 > Save.

  1. Go to Instances to view all VMSS instances — the count should now show 3.
  2. To upgrade all instances with a new image/config: go to Instances >

select all checkboxes > Upgrade (rolls out the new model progressively

based on the upgrade policy).

Validation

> select the set > Instances)

> Availability)

(vmss-lab09 > Instances)

(vmss-lab09 > Scaling)

Cleanup

  1. Resource groups > select rg-az104-lab09 > Delete resource group.

Exam Tips