The First Azure Virtual Machine
Deploying the Contractor Document Portal·55 minutes
Deploying the Contractor Document Portal
The network is ready. The governance framework is in place. Now it is time to deploy the first production workload: the Contractor Document Portal. This is a Windows Server virtual machine that will host the application used by Snips Housing contractors to submit and retrieve documents.
This is a significant moment — the first real workload in the Snips Azure environment. You need to choose the right VM size, configure the disks correctly, attach it to the right subnet and ensure it is protected against hardware failures.
What you will learn
VM images and sizes
Every Azure VM is created from an image — a template that contains the OS and optionally pre-installed software. Images come from the Azure Marketplace (Microsoft, third-party publishers) or from your own custom images captured from existing VMs.
VM size
Defines the number of vCPUs, amount of RAM, maximum number of data disks and network bandwidth. Sizes are grouped into families.
B-series (burstable)
Accumulates CPU credits during idle periods and spends them during bursts. Cost-effective for workloads with intermittent CPU demand.
D-series (general purpose)
Balanced CPU-to-memory ratio. Suitable for most production workloads including web servers and databases.
F-series (compute optimised)
High CPU-to-memory ratio. Best for batch processing, web servers and analytics workloads.
Virtual disks
Every Azure VM has at least one disk. Understanding the disk types is essential for both performance and cost management.
OS disk
Contains the operating system. Created automatically when you create a VM. Persists when the VM is deallocated. Deleted by default when the VM is deleted (configurable).
Data disk
Additional managed disks attached to the VM for application data, databases or logs. You control the size, type and lifecycle independently of the VM.
Temporary disk
Local SSD attached to the physical host. Fast but ephemeral — data is lost when the VM is deallocated or moved. Never store important data here.
Availability sets
A single VM has no protection against hardware failures. If the physical host fails, the VM goes down. Availability sets distribute VMs across fault domains and update domains to reduce the impact of failures and planned maintenance.
Fault domain
A group of VMs that share the same power supply and network switch (a rack). Distributing VMs across fault domains protects against rack-level hardware failures.
Update domain
A group of VMs that are rebooted together during planned Azure maintenance. Distributing across update domains ensures not all VMs restart simultaneously.
VM lifecycle
Understanding VM states is critical for cost management. Many administrators are surprised to discover they are still being charged for a VM they thought was "off".
VM lifecycle states
Select a state to understand its billing implications.
Deploying the VM with Azure CLI
The following commands create the Contractor Document Portal VM and attach it to the network built in Module 5. Note how the admin password is retrieved from Key Vault rather than typed directly — never pass passwords as plain text in scripts.
# Create a VM in the Snips production environment
az vm create \
--resource-group rg-compute-prod-uks-001 \
--name vm-contractordocportal-prod-uks-001 \
--image Win2022Datacenter \
--size Standard_B2s \
--vnet-name vnet-snips-prod-uks-001 \
--subnet snet-app-prod-uks-001 \
--availability-set as-contractordocportal-prod \
--admin-username snipsadmin \
--admin-password "$(az keyvault secret show --vault-name kv-snips-prod --name vm-admin-password --query value -o tsv)"
# Stop and deallocate (stops compute billing)
az vm deallocate \
--resource-group rg-compute-prod-uks-001 \
--name vm-contractordocportal-prod-uks-001
# Resize the VM
az vm resize \
--resource-group rg-compute-prod-uks-001 \
--name vm-contractordocportal-prod-uks-001 \
--size Standard_B4msVM extensions and boot diagnostics
VM extensions are small applications that run post-deployment configuration and automation tasks on Azure VMs. They are installed and managed by the Azure platform.
Custom Script Extension
Runs a PowerShell or shell script on the VM after deployment. Used to install software, configure settings or join a domain.
Azure Monitor Agent
Collects performance metrics and logs from the VM and sends them to a Log Analytics workspace for monitoring and alerting.
Boot diagnostics
Captures a screenshot of the VM console and serial log output. Essential for diagnosing VMs that fail to start or become unresponsive.
Azure Disk Encryption
Encrypts OS and data disks using BitLocker (Windows) or DM-Crypt (Linux), with keys stored in Azure Key Vault.
In your Azure subscription, complete the following tasks:
- 1.Create a resource group
rg-compute-prod-uks-001in UK South. - 2.Create an availability set with 2 fault domains and 5 update domains.
- 3.Deploy a Windows Server 2022 VM (Standard_B2s) in the availability set, attached to the VNet from Module 5.
- 4.Enable boot diagnostics on the VM.
- 5.Stop the VM using the Azure Portal and confirm it shows as "Deallocated".
- 6.Resize the VM to Standard_B4ms, then resize it back to Standard_B2s.
1.Snips needs to deploy a VM that can handle unpredictable CPU spikes. Which VM size family is best suited to burstable workloads?
2.You stop a VM in the Azure Portal using the "Stop" button. What billing state does the VM enter?
3.The Contractor Document Portal VM needs its OS disk to survive a VM deletion. Which disk configuration achieves this?
4.Snips wants the Contractor Document Portal VM to be protected against a single rack failure in the Azure data centre. Which availability option should you choose?
5.After deploying the VM, you realise you chose the wrong size. What is the correct way to resize it?
Module summary
The Contractor Document Portal VM is deployed. You have chosen an appropriate size, configured managed disks, placed the VM in an availability set and understand the lifecycle states that affect billing. The Snips Azure environment now has its first production workload.
Ready to mark this module complete?
Mark complete when you have read all sections, attempted the lab and completed the knowledge check.
- Deploy and manage Azure compute resources