Lab 1: Build a Secure Web Application Environment with Network, VMs, Load Balancer and Bastion

Microsoft Certified Azure Administrator Associate AZ 103 90 min min read Updated: Nov 17, 2026 Intermediate
Lab 1: Build a Secure Web Application Environment with Network, VMs, Load Balancer and Bastion
Intermediate Topic 1 of 3

Goal

text Internet -> Standard Load Balancer (public IP) -> web01, web02 (zones 1 and 2, no public IPs, nginx) Admins -> Azure Bastion -> VMs Monitoring: CPU alert + action group Backup: Recovery Services vault
Cost Bastion, Standard Load Balancer and VMs cost money. Use small sizes, and run the cleanup step at the end.

Step 1: Resource Group and Network

bash az group create -n rg-lab1 -l centralindia --tags Purpose=Lab az network vnet create -g rg-lab1 -n vnet-lab --address-prefixes 10.30.0.0/16 --subnet-name web --subnet-prefixes 10.30.1.0/24 az network vnet subnet create -g rg-lab1 --vnet-name vnet-lab -n AzureBastionSubnet --address-prefixes 10.30.250.0/26 az network nsg create -g rg-lab1 -n nsg-web az network nsg rule create -g rg-lab1 --nsg-name nsg-web -n allow-http --priority 100 --protocol Tcp --destination-port-ranges 80 --access Allow --source-address-prefixes Internet az network vnet subnet update -g rg-lab1 --vnet-name vnet-lab -n web --network-security-group nsg-web

Step 2: Two Web VMs With nginx

bash cat > cloud-init.txt <<'CLOUDINIT' #cloud-config package_update: true packages: [nginx] runcmd: - echo "Hello from $(hostname)" > /var/www/html/index.html CLOUDINIT for i in 1 2; do az vm create -g rg-lab1 -n web0$i --image Ubuntu2204 --size Standard_B1s --vnet-name vnet-lab --subnet web --public-ip-address "" \ --nsg "" --zone $i --custom-data cloud-init.txt --admin-username azureuser --generate-ssh-keys --no-wait done az vm wait -g rg-lab1 -n web02 --created

Step 3: Load Balancer

bash az network public-ip create -g rg-lab1 -n pip-lb --sku Standard --zone 1 2 3 az network lb create -g rg-lab1 -n lb-web --sku Standard --public-ip-address pip-lb --frontend-ip-name fe --backend-pool-name be az network lb probe create -g rg-lab1 --lb-name lb-web -n http-probe --protocol Http --port 80 --path / az network lb rule create -g rg-lab1 --lb-name lb-web -n http-rule --protocol Tcp --frontend-port 80 --backend-port 80 --frontend-ip-name fe --backend-pool-name be --probe-name http-probe for i in 1 2; do az network nic ip-config address-pool add -g rg-lab1 --nic-name web0${i}VMNic --ip-config-name ipconfigweb0$i --lb-name lb-web --address-pool be done az network public-ip show -g rg-lab1 -n pip-lb --query ipAddress -o tsv

Open the IP in a browser and refresh. You should see web01 and web02 answering. Because the VMs have no public IP, installing nginx needs an outbound path. If the install fails, add a NAT Gateway to the subnet, or use a temporary public IP for the build.

Step 4: Bastion

bash az network public-ip create -g rg-lab1 -n pip-bastion --sku Standard az network bastion create -g rg-lab1 -n bastion-lab --vnet-name vnet-lab --public-ip-address pip-bastion --sku Basic

In the portal open a VM, choose Connect > Bastion and sign in with your SSH key. No public IP or open SSH port is needed.

Step 5: Monitoring and Backup

bash az monitor action-group create -g rg-lab1 -n ag-lab --short-name lab --action email me you@example.com az monitor metrics alert create -g rg-lab1 -n cpu-alert --scopes $(az vm show -g rg-lab1 -n web01 --query id -o tsv) --condition "avg Percentage CPU > 80" --window-size 5m --evaluation-frequency 1m --severity 2 --action ag-lab az backup vault create -g rg-lab1 -n rsv-lab --location centralindia az backup protection enable-for-vm -g rg-lab1 -v rsv-lab --vm web01 --policy-name DefaultPolicy

Step 6: Test

  1. Stop nginx on web01 (sudo systemctl stop nginx through Bastion) and refresh the browser. Only web02 answers
  2. Start it again and watch the probe recover
  3. Use Network Watcher IP flow verify to confirm SSH from the internet is denied
  4. Check Metrics for the load balancer health probe status

Step 7: Clean Up

bash az group delete -n rg-lab1 --yes --no-wait

What You Practiced

  • Resource groups, tags, VNets, subnets, NSGs
  • VMs across zones, load balancing and probes
  • Bastion, alerts, action groups and backup
  • Troubleshooting with Network Watcher

Conclusion

You built a secure web environment: private VMs in zones behind a Standard load balancer, Bastion access, alerts and backup, then tested failure and cleaned up.

Quick Summary: goal; network; VMs; load balancer; Bastion; monitoring and backup; test; cleanup.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators