Lab 08: Manage Azure Virtual Machines
I’m Amir Rouhanipoor, an IT Consultant specializing in Azure and cloud solutions. I help organizations streamline their IT and drive growth through secure, efficient cloud technologies.
Search for a command to run...
I’m Amir Rouhanipoor, an IT Consultant specializing in Azure and cloud solutions. I help organizations streamline their IT and drive growth through secure, efficient cloud technologies.
No comments yet. Be the first to comment.
Objective: This lab introduces Azure Web Apps. You'll create a web app, deploy a simple "Hello World" application from GitHub, configure a staging slot, swap slots, and configure autoscaling. Scenario: Your organization is migrating on-premises websi...
PowerShell Script for VM Size Comparison This script lists all session hosts with their host pool, VM name, and VM size across all host pools(loop through multiple resource groups): Connect-AzAccount # Get all host pools $hostPools = Get-AzWvdHostPo...
M03 - Unit 4: Configure an ExpressRoute Gateway Exercise Scenario To connect your Azure virtual network to your on-premises network using ExpressRoute, you must first create a virtual network gateway. A virtual network gateway serves two key purposes...
M02-Unit 3 Create and configure a virtual network gateway Scenario You will configure a VPN gateway to securely connect CoreServicesVnet (East US) and ManufacturingVnet (North Europe) using VNet-to-VNet VPN. Task 1: Create CoreServicesVnet and Manuf...
Introduction Azure ExpressRoute is a private, enterprise-grade connection that enables secure and reliable network connectivity between your on-premises infrastructure and Microsoft’s global network. It bypasses the public internet and provides high ...
You need to create three virtual networks: 1. CoreServicesVnet Region: East US Purpose: Main network (web services, databases, shared services like DC/DNS). Connectivity: Needs VPN connection to on-premises. Address Space: Large (because of expe...
Security-focused Cloud & Automation Engineer with a Master’s in Computer Science and 6+ years of experience automating and supporting enterprise IT environments across multi-site corporate and operational infrastructures. Proficient in Python scripting, Azure infrastructure, Windows Server, and identity management. Skilled in integrating third-party platforms, securing configurations, and streamlining operations. Currently pursuing the Cybersecurity Architect Expert certification with a strong focus on cloud security and automation.
For complete lab instructions, see the full guide on GitHub.
Objective: This lab explores Azure Virtual Machines (VMs) and Virtual Machine Scale Sets (VMSS). You'll create and manage individual VMs, resize them, and then create a VMSS with autoscaling.
Key Concepts:
Availability Zones: Physically separate locations within an Azure region, providing high availability and fault tolerance. Deploying VMs across zones protects against single-point-of-failure within a region.
VM Size (SKU): Determines the compute resources (CPU, memory) allocated to a VM. Resizing a VM changes its SKU.
Managed Disks: Azure-managed storage for VMs. You can change the disk type (Standard HDD, Standard SSD, Premium SSD) and size.
Virtual Machine Scale Set (VMSS): A group of identical, load-balanced VMs that can automatically scale in or out based on demand or a schedule.
Autoscaling: Automatically adjusting the number of VM instances in a VMSS based on metrics like CPU utilization.
Orchestration Modes: Uniform (identical instances, suitable for stateless applications, the focus of this lab) and Flexible (allows more heterogeneity, suitable for a wider range of workloads, including stateful applications).
Task 1: Deploy zone-resilient Azure virtual machines by using the Azure portal.
Task 2: Manage compute and storage scaling for virtual machines.
Task 3: Create and configure Azure Virtual Machine Scale Sets.
Task 4: Scale Azure Virtual Machine Scale Sets.
Task 5: Create a virtual machine using Azure PowerShell (optional 1).
Task 6: Create a virtual machine using the CLI (optional 2).
Task 1: Deploy Zone-Resilient VMs
Sign In: Log in to the Azure portal (https://portal.azure.com).
Create VMs: Search for and select "Virtual machines" and click "+ Create" -> "Azure virtual machine."
Basics:
Virtual machine names: After selecting both Availability Zones (next step), select Edit Names and use az104-vm1 and az104-vm2.
Availability options: Availability zone
Availability zone: Check both Zone 1 and Zone 2. This creates two VMs, one in each zone.
Azure Spot instance: Unchecked
Size: Standard_D2s_v3
Password: (Provide a strong password)
Public inbound ports: None
Disks:
OS disk type: Premium SSD
Delete with VM: Checked (default)
Enable Ultra Disk compatibility: Unchecked
Networking: Accept the defaults, but set Load Balancing Options to None and Delete public IP and NIC when VM is deleted to Checked.
Management: Patch orchestration options: Azure orchestrated
Monitoring:Boot diagnostics: Disable
Advanced: Accept the defaults.
Review + create: Verify and click "Create."
Task 2: Manage VM Scaling
Resize VM (Vertical Scaling):
Go to the az104-vm1 VM resource.
Under "Settings," select "Size."
Choose Standard_DS1_v2
Click "Resize." Confirm the change if prompted.
Manage Data Disk:
Under "Settings," select "Disks."
Click "+ Create and attach a new disk."
Disk name: vm1-disk1
Storage type: Standard HDD
Size (GiB): 32
Click "Save."
After creation, click the "Detach" icon (far right) for vm1-disk1.
Click Apply. This detaches the disk but keeps it in storage.
Change Disk Type:
Search for and select "Disks."
Select vm1-disk1.
Under "Settings," select "Size + performance."
Change the "Storage type" to Standard SSD.
Click "Save."
Reattach Disk:
Go back to the az104-vm1 VM.
Select "Disks."
Under "Data disks," click "Attach existing disks."
Disk name: Select vm1-disk1.
Verify the disk type is now Standard SSD.
Click Apply.
Task 3: Create Virtual Machine Scale Set
Create VMSS: Search for and select "Virtual machine scale sets." and click "+ Create."
Basics:
Virtual machine scale set name: vmss1
Region: (US) East US
Availability zone: Select Zone 1, Zone 2, and Zone 3.
Orchestration mode: Uniform
Scaling Options: Review and take the defaults. We will change this in the next task.
Size: Standard_D2s_v3
Disks: Accept the defaults.

Networking: Click "Create virtual network" (below the Virtual network textbox).
Name: vmss-vnet
Address range: 10.82.0.0/20 (delete the existing default range)
Subnet name: subnet0
Subnet range: 10.82.0.0/24
Click "OK."
Click the "Edit network interface" icon (pencil) to the right of the NIC entry.
NIC network security group: Advanced
Configure network security group: Click "Create new."
Name: vmss1-nsg
Click "Add an inbound rule."
Source: Any
Source port ranges: *
Destination: Any
Service: HTTP
Action: Allow
Priority: 1010
Name: allow-http
Click "Add."
Click "OK."

Public IP address: Enabled
Click "OK."

Load Balancing:
Load balancing options: Azure load balancer
Select a load balancer: Click Create new
Enter the Load Balancer Name: vmss-lb
Take the defaults, and select Create.

Management: Disable Boot Diagnostics.
Health: Review the defaults (no changes).
Advanced: Review the defaults (no changes).
Review + create: Verify and click "Create."
Task 4: Scale VMSS (Autoscaling)
Configure Autoscaling:
Go to the vmss1 resource.
Under Settings, choose Availability + Scale, and then Scaling.
Select Custom autoscale.
Scale mode: Scale based on a metric
Click "+ Add a rule."
Scale Out Rule (Increase Instances):
Metric source: Current resource (vmss1)
Metric namespace: Virtual Machine Host
Metric name: Percentage CPU
Operator: Greater than
Metric threshold to trigger scale action: 70
Duration (minutes): 10
Time grain statistic: Average
Operation: Increase percent by
Cool down (minutes): 5
Percentage: 50
Select Add.

Scale In Rule (Decrease Instances):
Select Add a rule
Metric Source: Current Resource
Metric namespace: Virtual Machine Host
Metric name: Percentage CPU
Operator: Less than
Threshold: 30
Operation: Decrease percent by
Percentage: 50
Select Add.
Instance Limits:
Minimum: 2
Maximum: 10
Default: 2
Click "Save."


vmss1 page, select "Instances." This is where you'd monitor the number of running VM instances as the scale set scales in and out.
Task 5: Create VM with PowerShell (Optional)
Launch Cloud Shell (PowerShell): Click the Cloud Shell icon in the portal (or go to https://shell.azure.com). Choose PowerShell.
Create VM:
PowerShell
New-AzVm `
-ResourceGroupName 'az104-rg8' `
-Name 'myPSVM' `
-Location 'East US' `
-Image 'Win2019Datacenter' `
-Zone '1' `
-Size 'Standard_D2s_v3' `
-Credential (Get-Credential)
Enter a username and password when prompted.
Verify and Deallocate:
PowerShell
Get-AzVM -ResourceGroupName 'az104-rg8' -Status
Stop-AzVM -ResourceGroupName 'az104-rg8' -Name 'myPSVM' -Force
Get-AzVM -ResourceGroupName 'az104-rg8' -Status
Task 6: Create VM with Azure CLI (Optional)
Launch Cloud Shell (Bash): Click the Cloud Shell icon, and choose Bash.
Create VM:
Bash
az vm create --name myCLIVM --resource-group az104-rg8 --image Ubuntu2204 --admin-username localadmin --generate-ssh-keys
Verify and Deallocate:
Bash
az vm show --name myCLIVM --resource-group az104-rg8 --show-details
az vm deallocate --resource-group az104-rg8 --name myCLIVM
az vm show --name myCLIVM --resource-group az104-rg8 --show-details
For complete lab instructions, see the full guide on GitHub.