Back to Main AZ-104 Hub
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.

  1. Sign in to the Azure portal.
  2. In the search bar, type Virtual machines and select it. Click + Create > Azure virtual machine.
  3. Basics Tab: Select your Resource Group. Enter the VM name AZ104-VM1.
  4. For Availability options, select Availability zone. In the drop-down that appears, select Zone 1.
  5. For the Image, select Windows Server 2022 Datacenter: Azure Edition.
  6. Enter a secure Administrator username and password. Note these down.
  7. Under Inbound port rules, choose Allow selected ports and check HTTP (80) and RDP (3389).
  8. Click Review + create, then click Create. 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.

  1. In the portal search bar, type Virtual machine scale sets and select it.
  2. Click + Create. Name the scale set AZ104-VMSS. Choose the same region as before and select the Windows Server 2022 image.
  3. Provide administrator credentials.
  4. Skip to the Scaling tab. Set the Initial instance count to 2.
  5. Change the Scaling policy from Manual to Custom.
  6. Configure the Auto-scale rules:
    • Minimum instances: 1
    • Maximum instances: 4
    • Scale out: CPU threshold 75%, Increase by 1
    • Scale in: CPU threshold 25%, Decrease by 1
  7. Click Review + create, then click Create.
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.

  1. Create a simple text file on your local computer named install-iis.ps1.
  2. Open the file in Notepad, paste the following line, and save it:
    Install-WindowsFeature -name Web-Server -IncludeManagementTools
  3. In the Azure portal, navigate back to the AZ104-VM1 virtual machine you created in Exercise 1.
  4. On the left-hand menu, scroll down to the Settings section and select Extensions + applications.
  5. Click + Add. Scroll down and select Custom Script Extension, then click Next.
  6. Click Browse and upload the install-iis.ps1 file you just created. Click Review + create and Create.
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!
Follow on LinkedIn