MS Learn Module 8 Practical
Implement and Manage Virtual Machines
Deploy compute resources in Azure. Learn to configure high availability, implement auto-scaling with Virtual Machine Scale Sets, and automate VM configuration using extensions.
Concept Refresher: Azure offers multiple ways to ensure high availability for VMs. An Availability Set protects your VMs from hardware failures within a single datacenter rack (fault domains/update domains). An Availability Zone protects your VMs from entire datacenter failures by physically separating them across different buildings within the same region.
Exercise 1: Deploy a Highly Available Virtual Machine
We will create a Windows Virtual Machine and place it specifically into an Availability Zone to ensure maximum uptime protection.
- Sign in to the Azure portal.
- In the search bar, type
Virtual machinesand select it. Click+ Create>Azure virtual machine. - Basics Tab: Select your Resource Group. Enter the VM name
AZ104-VM1. - For Availability options, select
Availability zone. In the drop-down that appears, selectZone 1. - For the Image, select
Windows Server 2022 Datacenter: Azure Edition. - Enter a secure Administrator username and password. Note these down.
- Under Inbound port rules, choose
Allow selected portsand check HTTP (80) and RDP (3389). - Click
Review + create, then clickCreate. Wait for deployment to finish.
Exercise 2: Create a Virtual Machine Scale Set (VMSS)
A Scale Set allows you to deploy and manage a group of identical, load-balanced VMs. The number of VM instances can automatically increase or decrease in response to demand or a defined schedule.
- In the portal search bar, type
Virtual machine scale setsand select it. - Click
+ Create. Name the scale setAZ104-VMSS. Choose the same region as before and select the Windows Server 2022 image. - Provide administrator credentials.
- Skip to the Scaling tab. Set the Initial instance count to
2. - Change the Scaling policy from Manual to
Custom. - Configure the Auto-scale rules:
- Minimum instances: 1
- Maximum instances: 4
- Scale out: CPU threshold
75%, Increase by1 - Scale in: CPU threshold
25%, Decrease by1
- Click
Review + create, then clickCreate.
Observation: Once deployed, if the CPU across the 2 initial instances spikes above 75% for a sustained period, Azure will automatically spin up a 3rd instance to handle the load without any administrative intervention.
Exercise 3: Automate Configuration via Custom Script Extension
Deploying a VM is only step one. Usually, you need to install software on it. Instead of manually RDP-ing into the server, we will use a Custom Script Extension to automatically install IIS (Web Server) via PowerShell.
- Create a simple text file on your local computer named
install-iis.ps1. - Open the file in Notepad, paste the following line, and save it:
Install-WindowsFeature -name Web-Server -IncludeManagementTools - In the Azure portal, navigate back to the
AZ104-VM1virtual machine you created in Exercise 1. - On the left-hand menu, scroll down to the Settings section and select
Extensions + applications. - Click
+ Add. Scroll down and selectCustom Script Extension, then clickNext. - Click
Browseand upload theinstall-iis.ps1file you just created. ClickReview + createandCreate.
Verification: Wait a few minutes for the extension to report "Provisioning succeeded". Go to the Overview page of your VM, copy the Public IP address, and paste it into a new browser tab. You should see the default Windows IIS welcome page!