Lab 3: Governance, Automation and Recovery: RBAC, Policy, Bicep Deployment, Alerts, Backup and Restore

Microsoft Certified Azure Administrator Associate AZ 103 100 min min read Updated: Nov 17, 2026 Advanced
Lab 3: Governance, Automation and Recovery: RBAC, Policy, Bicep Deployment, Alerts, Backup and Restore
Advanced Topic 3 of 3

Goal

  • Create a Dev resource group governed by Policy and RBAC
  • Deploy a VM and storage account from Bicep
  • Add monitoring, alerts and backup
  • Break something, then recover

Step 1: Group, RBAC and Tags

bash az group create -n rg-lab3 -l centralindia --tags Environment=Dev Owner=you az ad group create --display-name "Lab3-Operators" --mail-nickname lab3ops az role assignment create --assignee-object-id $(az ad group show -g "Lab3-Operators" --query id -o tsv) --assignee-principal-type Group \ --role "Virtual Machine Contributor" --resource-group rg-lab3

Step 2: Policy and Lock

bash # Require an Owner tag on resources in the group (built-in definition "Require a tag on resources") DEF=$(az policy definition list --query "[?displayName=='Require a tag on resources'].name | [0]" -o tsv) az policy assignment create --name require-owner --policy $DEF --params '{"tagName":{"value":"Owner"}}' --resource-group rg-lab3 az lock create --name no-delete --lock-type CanNotDelete --resource-group rg-lab3

Try to create a resource without an Owner tag. It should be denied. Then try to delete the resource group. The lock should stop you (remove it in the cleanup step).

Step 3: Deploy With Bicep

bicep param location string = resourceGroup().location param adminUser string = 'azureuser' @secure() param sshKey string var suffix = uniqueString(resourceGroup().id) resource storage 'Microsoft.Storage/storageAccounts@2023-05-01' = { name: 'stlab3${suffix}' location: location tags: { Owner: 'you', Environment: 'Dev' } sku: { name: 'Standard_LRS' } kind: 'StorageV2' properties: { minimumTlsVersion: 'TLS1_2', allowBlobPublicAccess: false } } resource vnet 'Microsoft.Network/virtualNetworks@2023-11-01' = { name: 'vnet-lab3' location: location tags: { Owner: 'you' } properties: { addressSpace: { addressPrefixes: ['10.40.0.0/16'] } subnets: [{ name: 'default', properties: { addressPrefix: '10.40.1.0/24' } }] } } resource nic 'Microsoft.Network/networkInterfaces@2023-11-01' = { name: 'nic-lab3' location: location tags: { Owner: 'you' } properties: { ipConfigurations: [{ name: 'ipconfig1', properties: { subnet: { id: vnet.properties.subnets[0].id }, privateIPAllocationMethod: 'Dynamic' } }] } } resource vm 'Microsoft.Compute/virtualMachines@2024-03-01' = { name: 'vm-lab3' location: location tags: { Owner: 'you' } properties: { hardwareProfile: { vmSize: 'Standard_B1s' } osProfile: { computerName: 'vmlab3', adminUsername: adminUser, linuxConfiguration: { disablePasswordAuthentication: true, ssh: { publicKeys: [{ path: '/home/${adminUser}/.ssh/authorized_keys', keyData: sshKey }] } } } storageProfile: { imageReference: { publisher: 'Canonical', offer: '0001-com-ubuntu-server-jammy', sku: '22_04-lts-gen2', version: 'latest' }, osDisk: { createOption: 'FromImage' } } networkProfile: { networkInterfaces: [{ id: nic.id }] } } }
bash az deployment group what-if -g rg-lab3 -f main.bicep -p sshKey="$(cat ~/.ssh/id_rsa.pub)" az deployment group create -g rg-lab3 -f main.bicep -p sshKey="$(cat ~/.ssh/id_rsa.pub)"
Note The API versions and image names above change over time. Use the Bicep VS Code extension to pick current ones.

Step 4: Monitoring

bash az monitor log-analytics workspace create -g rg-lab3 -n law-lab3 --tags Owner=you az monitor action-group create -g rg-lab3 -n ag-lab3 --short-name lab3 --action email me you@example.com az monitor metrics alert create -g rg-lab3 -n vm-cpu --scopes $(az vm show -g rg-lab3 -n vm-lab3 --query id -o tsv) --condition "avg Percentage CPU > 80" --window-size 5m --evaluation-frequency 1m --action ag-lab3

Step 5: Backup, Break and Restore

bash az backup vault create -g rg-lab3 -n rsv-lab3 --location centralindia az backup protection enable-for-vm -g rg-lab3 -v rsv-lab3 --vm vm-lab3 --policy-name DefaultPolicy # Create a test file BEFORE the backup runs, so the recovery point contains it az vm run-command invoke -g rg-lab3 -n vm-lab3 --command-id RunShellScript --scripts "echo important > /home/azureuser/data.txt" az backup protection backup-now -g rg-lab3 -v rsv-lab3 -c vm-lab3 -i vm-lab3 --backup-management-type AzureIaasVM --workload-type VM --retain-until 31-12-2026
  1. The test file is created first, then the backup runs, so the recovery point contains it
  2. Wait for the backup job to finish (az backup job list)
  3. Delete /home/azureuser/data.txt with Run command
  4. Open the VM Backup > File Recovery, download the script, mount the recovery point and copy the file back
  5. Optionally restore the whole VM to a new name

Step 6: Review Evidence

  • Policy compliance page shows the Owner tag policy
  • Activity log shows who deployed and who deleted the file or resource
  • Alert fired or tested, backup job succeeded

Clean Up

bash az lock delete --name no-delete --resource-group rg-lab3 az policy assignment delete --name require-owner --resource-group rg-lab3 az group delete -n rg-lab3 --yes --no-wait

If vault deletion fails, stop protection and delete backup data first (soft delete may keep items for 14 days).

Conclusion

You applied governance with RBAC, tags, Policy and locks, deployed infrastructure with Bicep, added monitoring, and proved recovery by restoring a file from backup.

Quick Summary: goal; RBAC; policy; Bicep; monitoring; backup and restore; evidence; cleanup.

Get Newsletter

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