Assignments
25 hands-on assignments in three levels: 10 ๐ข Beginner, 10 ๐ก Intermediate, 5 ๐ด Advanced. Do them in a sandbox subscription, tag everything, and delete what you create.
How to use these
Use the Azure CLI (and Terraform or Bicep where asked) for every task, even where the portal is quicker. The CLI is what you will script and put in pipelines. Before you start, set a budget on the subscription. Work in one region (centralindia in our examples) and tag every resource group with project, env and owner, so cleanup is az group delete on a known list. Hints are collapsed so you can try first.
๐ข Beginner
Assignment 1. Set up a safe working subscription ๐ข
Objective: Get a subscription ready for practice with cost guardrails and correct CLI context.
Tasks
- Log in with
az login, list subscriptions and set the one you will use as default. - Create a monthly budget of 20 USD on the subscription that emails you at 50%, 80% and 100% of forecast.
- Create a resource group
rg-practice-cinincentralindiawith tagsproject=practice env=lab owner=<you>. - Print your own object ID and confirm your role at subscription scope.
Expected outcome / acceptance criteria: az account show shows the right subscription; the budget is visible in Cost Management; az group show -n rg-practice-cin --query tags returns all three tags; az role assignment list --assignee <your-oid> --include-inherited shows Owner or Contributor.
Hints
az account set --subscription, az consumption budget create --category cost --time-grain Monthly, az group create --tags k=v k2=v2, az ad signed-in-user show --query id -o tsv. Notifications on budgets are easier in the portal the first time; then export the JSON and recreate it with the CLI.
Bonus: Create a subscription diagnostic setting that sends the Activity Log to a Log Analytics workspace.
Assignment 2. Explore the resource hierarchy ๐ข
Objective: Understand tenants, management groups, subscriptions and resource groups from the CLI.
Tasks
- Show your tenant ID and the tenants you can access.
- List management groups you can see (it may be just the root).
- List all resource groups in the subscription with their locations and tags in a table.
- Use Azure Resource Graph to count resources by type across the subscription.
Expected outcome / acceptance criteria: A short note in your own words explaining tenant โ management group โ subscription โ resource group, with the actual IDs from your environment.
Hints
az account tenant list, az account management-group list, az group list --query "[].{name:name, loc:location, tags:tags}" -o table, az graph query -q "Resources | summarize count() by type | order by count_ desc" (needs az extension add -n resource-graph).
Bonus: Create a management group mg-practice and move your subscription under it (only in a personal tenant).
Assignment 3. Build a VNet with NSGs ๐ข
Objective: Create a VNet with two subnets and control traffic between them with NSGs.
Tasks
- Create
vnet-practicewith address space10.50.0.0/16and subnetssnet-web(10.50.1.0/24) andsnet-app(10.50.2.0/24). - Create NSG
nsg-weballowing inbound 80 and 443 fromInternet, and NSGnsg-appallowing inbound 8080 only from10.50.1.0/24. - Associate each NSG with its subnet.
- List the rules of both NSGs including default rules.
Expected outcome / acceptance criteria: az network vnet subnet list shows both subnets with their NSGs; nsg-app has no rule that allows traffic from Internet.
Hints
az network vnet create --subnet-name --subnet-prefixes, az network vnet subnet create, az network nsg rule create --priority 100 --source-address-prefixes, az network vnet subnet update --network-security-group, az network nsg rule list --include-default -o table.
Bonus: Replace the source CIDR in nsg-app with an Application Security Group asg-web attached to the web VM NICs.
Assignment 4. Launch a Linux VM with no public IP and connect safely ๐ข
Objective: Run a VM you can manage without exposing SSH to the internet.
Tasks
- Create an Ubuntu VM in
snet-appwith--public-ip-address ""and a system-assigned managed identity. - Install nginx with cloud-init (
--custom-data). - Run a command on it with
az vm run-command invoketo check nginx is active. - Enable auto-shutdown at 20:00 local time.
Expected outcome / acceptance criteria: The VM has no public IP; run-command returns active; az vm show -d --query publicIps is empty; the auto-shutdown schedule exists.
Hints
az vm create --image Ubuntu2204 --size Standard_B2s --assign-identity --custom-data cloud-init.yaml --nsg "". az vm run-command invoke --command-id RunShellScript --scripts "systemctl is-active nginx". az vm auto-shutdown --time 1430 uses UTC.
Bonus: Deploy Azure Bastion (Developer SKU if available in your region) and connect with az network bastion ssh.
Assignment 5. Storage account done right ๐ข
Objective: Create a locked-down storage account and access it with Entra ID, not keys.
Tasks
- Create a StorageV2 account with ZRS, TLS 1.2 minimum, blob public access disabled.
- Give yourself
Storage Blob Data Contributoron the account. - Create a container
reportsand upload a file using--auth-mode login. - Generate a user delegation SAS for that blob valid for 1 hour, and download it with
curl.
Expected outcome / acceptance criteria: Upload works with --auth-mode login; the SAS URL downloads the file; after the expiry, the same URL returns AuthenticationFailed.
Hints
az storage account create --sku Standard_ZRS --min-tls-version TLS1_2 --allow-blob-public-access false. az storage blob generate-sas --as-user --auth-mode login --permissions r --expiry <UTC> --full-uri.
Bonus: Add a lifecycle rule that moves blobs under reports/ to Cool after 30 days and deletes them after 365.
Assignment 6. Key Vault with RBAC ๐ข
Objective: Store and read secrets with Azure RBAC data-plane roles.
Tasks
- Create a Key Vault with RBAC authorization enabled and soft-delete retention of 7 days.
- Try
az keyvault secret setbefore giving yourself any data role, and record the error. - Assign yourself
Key Vault Secrets Officerand set a secretapi-key. - Give the VM from Assignment 4
Key Vault Secrets User, then read the secret from inside the VM with its managed identity.
Expected outcome / acceptance criteria: Step 2 fails with ForbiddenByRbac; step 4 prints the secret from the VM via az login --identity or a curl to IMDS plus the Key Vault REST API.
Hints
az keyvault create --enable-rbac-authorization true --retention-days 7. On the VM: get a token from http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https://vault.azure.net with header Metadata:true, then GET https://<vault>.vault.azure.net/secrets/api-key?api-version=7.4.
Bonus: Delete the vault, show it in az keyvault list-deleted, then recover it.
Assignment 7. Push your first image to ACR ๐ข
Objective: Build and store container images in Azure Container Registry.
Tasks
- Create an ACR (Basic SKU) with the admin user disabled.
- Write a tiny Dockerfile (any web server) and build it in the cloud with
az acr build. - Import
nginx:1.27from Docker Hub intobase/nginx:1.27. - List repositories and tags.
Expected outcome / acceptance criteria: Two repositories exist, with tags visible in az acr repository show-tags; az acr show --query adminUserEnabled returns false.
Hints
az acr create --sku Basic --admin-enabled false, az acr build -r <acr> -t hello:v1 ., az acr import --source docker.io/library/nginx:1.27 --image base/nginx:1.27.
Bonus: Run the image as an Azure Container Instance pulling from ACR with a user-assigned identity.
Assignment 8. Deploy a web app to App Service with slots ๐ข
Objective: Use deployment slots for zero-downtime releases.
Tasks
- Create a Linux App Service plan (S1) and a web app running a container image or a sample code app.
- Create a
stagingslot and deploy a visibly different version to it. - Add an app setting
ENV_NAMEas a slot setting with different values per slot. - Swap staging into production and confirm the sticky setting stayed with its slot.
Expected outcome / acceptance criteria: After the swap, production serves the new version and still reports ENV_NAME=production.
Hints
az appservice plan create --is-linux --sku S1, az webapp create --deployment-container-image-name, az webapp deployment slot create --slot staging, az webapp config appsettings set --slot-settings ENV_NAME=staging --slot staging, az webapp deployment slot swap.
Bonus: Turn on the @Microsoft.KeyVault(...) reference for one setting using the app's managed identity.
Assignment 9. Your first AKS cluster ๐ข
Objective: Create a small AKS cluster and run a workload pulled from your ACR.
Tasks
- Create a 2-node AKS cluster with managed identity and Azure CNI Overlay.
- Attach the ACR from Assignment 7 to the cluster.
- Get credentials, deploy your
hello:v1image with 2 replicas and a LoadBalancer Service. - Run
az aks check-acrand record the output.
Expected outcome / acceptance criteria: curl to the Service's external IP returns your app; kubectl get nodes shows 2 Ready nodes; check-acr reports success.
Hints
az aks create --node-count 2 --network-plugin azure --network-plugin-mode overlay --attach-acr <acr> --generate-ssh-keys. kubectl create deployment hello --image=<acr>.azurecr.io/hello:v1 --replicas=2 then kubectl expose deployment hello --type=LoadBalancer --port=80 --target-port=<port>.
Bonus: Stop the cluster with az aks stop, then start it again and confirm the app is back.
Assignment 10. Monitor a resource and alert on it ๐ข
Objective: Use Azure Monitor metrics, logs and alerts.
Tasks
- Create a Log Analytics workspace.
- Send the Key Vault from Assignment 6 audit logs to it with a diagnostic setting.
- Read the secret a few times, then query
AzureDiagnostics(orAZKVAuditLogs) forSecretGetoperations. - Create an action group with your email and a metric alert on the VM
Percentage CPU > 80.
Expected outcome / acceptance criteria: The KQL query returns your secret reads with caller identity; the alert rule shows up in az monitor metrics alert list.
Hints
az monitor diagnostic-settings create --logs '[{"categoryGroup":"audit","enabled":true}]'. Query: AzureDiagnostics | where ResourceProvider == "MICROSOFT.KEYVAULT" and OperationName == "SecretGet" | project TimeGenerated, CallerIPAddress, identity_claim_upn_s.
Bonus: Use stress-ng on the VM through run-command to make the alert fire.
๐ก Intermediate
Assignment 11. Least-privilege custom role ๐ก
Objective: Write and test a custom role for a narrow job.
Tasks
- Write a custom role "VM Operator" that can read, start, restart and deallocate VMs but not create or delete them.
- Create it with assignable scope set to your subscription.
- Assign it to a test user or a service principal on
rg-practice-cin. - Prove it works: start/stop succeeds;
az vm deletefails withAuthorizationFailed.
Expected outcome / acceptance criteria: Role JSON in your repo; screenshots or command outputs showing allowed and denied actions.
Hints
Actions: Microsoft.Compute/virtualMachines/read, /start/action, /restart/action, /deallocate/action, /powerOff/action, plus Microsoft.Resources/subscriptions/resourceGroups/read. Find names with az provider operation show -n Microsoft.Compute.
Bonus: Add an ABAC-style restriction by giving a second identity Role Based Access Control Administrator that can only assign your custom role.
Assignment 12. Hub-and-spoke with forced egress ๐ก
Objective: Build a hub-spoke network where spoke traffic to the internet and to other spokes goes through a central appliance.
Tasks
- Create
vnet-hub(10.60.0.0/16) and two spokes (10.61.0.0/16,10.62.0.0/16), peered hubโspoke both ways. - Deploy Azure Firewall Basic (or a Linux VM with IP forwarding as a cheap NVA) in the hub.
- Add UDRs on spoke subnets:
0.0.0.0/0and the other spoke CIDR โ firewall private IP. - Allow only spoke1 โ spoke2 on TCP 22 and outbound HTTPS to
*.ubuntu.com.
Expected outcome / acceptance criteria: A VM in spoke1 can SSH to spoke2 and run apt update, but curl https://example.com fails; az network watcher show-next-hop shows VirtualAppliance.
Hints
Peering flag --allow-forwarded-traffic on hub-to-spoke peerings. For an NVA VM: az network nic update --ip-forwarding true plus sysctl net.ipv4.ip_forward=1 and iptables MASQUERADE. Firewall rules: application rule collection for FQDNs, network rule collection for 22.
Bonus: Turn on VNet flow logs and find the denied flows in Traffic Analytics.
Assignment 13. Private Endpoint and private DNS ๐ก
Objective: Make a storage account or Key Vault reachable only privately, and get DNS right.
Tasks
- Create a Private Endpoint for your Key Vault in a spoke subnet with a DNS zone group for
privatelink.vaultcore.azure.net. - Link the private DNS zone to the VNet.
- Disable public network access on the vault.
- From a VM in the VNet, show
nslookup <vault>.vault.azure.netreturns a10.xIP and the secret read works; from your laptop show it fails.
Expected outcome / acceptance criteria: Private resolution inside, ForbiddenByFirewall or public-access-disabled error outside.
Hints
az network private-endpoint create --group-id vault --private-connection-resource-id <kvId>, az network private-dns zone create, az network private-dns link vnet create, az network private-endpoint dns-zone-group create, az keyvault update --public-network-access Disabled.
Bonus: Link the zone only to the hub and make the spoke resolve it through a DNS Private Resolver inbound endpoint.
Assignment 14. Terraform an environment with remote state ๐ก
Objective: Build an RG, VNet, ACR and Key Vault with Terraform azurerm v4 and a secure backend.
Tasks
- Create a state storage account with shared keys disabled and blob versioning on.
- Write Terraform with
backend "azurerm"usinguse_azuread_auth = true. - Create the resources with tags, a random suffix for globally unique names and outputs.
- Change a tag in the portal, then show the drift with
terraform plan -detailed-exitcode.
Expected outcome / acceptance criteria: plan exit code 0 after apply, 2 after the manual change; state blob has multiple versions.
Hints
Remember subscription_id in the provider block for v4. Give yourself Storage Blob Data Contributor on the state account. az storage blob list --include v shows versions.
Bonus: Import a resource group you created by hand using an import block and -generate-config-out.
Assignment 15. The same stack in Bicep ๐ก
Objective: Learn Bicep modules, parameters files and what-if.
Tasks
- Write
main.bicepwith modulesnetwork.bicep,acr.bicep,keyvault.bicep. - Use a
.bicepparamfile fordevand one forprodwith different SKUs. - Run
what-if, then deploydev. - Change a property and show the what-if diff before redeploying.
Expected outcome / acceptance criteria: Deployment succeeds; what-if output shows only the intended modification on the second run.
Hints
az deployment group what-if -g rg -f main.bicep -p dev.bicepparam. Use uniqueString(resourceGroup().id) for names. az bicep lint -f main.bicep catches common mistakes.
Bonus: Deploy it as a deployment stack with --deny-settings-mode denyDelete and try deleting a resource from the portal.
Assignment 16. GitHub Actions to Azure with OIDC ๐ก
Objective: Deploy from GitHub without any stored Azure secret.
Tasks
- Create a user-assigned identity and a federated credential for
repo:<you>/<repo>:environment:dev. - Give it Contributor on one resource group only.
- Write a workflow with
id-token: writethat logs in withazure/login@v2and runsaz group show. - Run it from a feature branch without the environment and capture the AADSTS error, then fix it.
Expected outcome / acceptance criteria: The dev environment job succeeds; the branch job fails with AADSTS70021 showing the subject it presented.
Hints
az identity federated-credential create --issuer https://token.actions.githubusercontent.com --subject ... --audiences api://AzureADTokenExchange. Store client, tenant and subscription IDs as GitHub variables; they are not secrets.
Bonus: Add a Reader-only identity federated for pull_request and run terraform plan on PRs with it.
Assignment 17. Azure DevOps YAML pipeline with environments ๐ก
Objective: Build a multi-stage Azure Pipelines deployment with approvals and a WIF service connection.
Tasks
- Create an Azure DevOps project and an ARM service connection using workload identity federation.
- Write
azure-pipelines.ymlwithBuildandDeploystages; Build produces an artifact, Deploy uses adeploymentjob. - Create environment
practice-prodwith an approval check and branch control formain. - Run from a non-main branch and show the deploy is blocked by the check.
Expected outcome / acceptance criteria: Pipeline run history shows the approval gate; the environment's deployments tab lists the run.
Hints
Use AzureCLI@2 with azureSubscription:. Publish artifacts with - publish: $(Build.ArtifactStagingDirectory) and consume with - download: current. Branch control lives under the environment's Approvals and checks.
Bonus: Move the stages into a template repo and use extends with the "Required template" check.
Assignment 18. Workload identity + Key Vault CSI on AKS ๐ก
Objective: Mount a Key Vault secret into a pod with no secret in Kubernetes manifests.
Tasks
- Enable
--enable-oidc-issuer --enable-workload-identityand theazure-keyvault-secrets-provideradd-on with rotation. - Create a user-assigned identity, grant it
Key Vault Secrets User, federate it tosystem:serviceaccount:demo:app-sa. - Deploy a ServiceAccount, SecretProviderClass and a Deployment that mounts the secret at
/mnt/secrets. - Rotate the secret and show the file updates without a pod restart.
Expected outcome / acceptance criteria: kubectl exec ... cat /mnt/secrets/<name> shows the new value within about 2 minutes of rotation; pod restart count is 0.
Hints
Pod label azure.workload.identity/use: "true", SA annotation azure.workload.identity/client-id. SecretProviderClass needs clientID, keyvaultName, tenantId, objects. Rotation: az aks addon update -a azure-keyvault-secrets-provider --enable-secret-rotation.
Bonus: Add secretObjects to sync into a Kubernetes Secret and use it as an env var; explain why the env var doesn't rotate.
Assignment 19. AKS node pools, taints and the autoscaler ๐ก
Objective: Separate system and user workloads and watch the autoscaler work.
Tasks
- Add a user node pool
appswith autoscaler 1โ4 across zones. - Taint the system pool with
CriticalAddonsOnly=true:NoSchedule(add a new tainted system pool if needed) and confirm app pods land onapps. - Scale a deployment so pods go Pending, and record the autoscaler events.
- Scale back and time how long scale-down takes; then change
scale-down-unneeded-timeand repeat.
Expected outcome / acceptance criteria: Events show TriggeredScaleUp; node count goes up and back down; you can explain the timing.
Hints
az aks nodepool add --mode User --enable-cluster-autoscaler --min-count 1 --max-count 4 --zones 1 2 3. kubectl get events -A --field-selector reason=TriggeredScaleUp. az aks update --cluster-autoscaler-profile scale-down-unneeded-time=3m.
Bonus: Add a Spot pool and schedule a CronJob onto it with the Spot toleration.
Assignment 20. Azure Policy guardrails ๐ก
Objective: Enforce governance with built-in and custom policies.
Tasks
- Assign "Allowed locations" for
centralindiaandsouthindiaon your practice RG. - Assign "Require a tag on resource groups" for
ownerat subscription scope in Audit mode, then check compliance. - Write a custom policy that denies storage accounts with
allowBlobPublicAccessset to true. - Show a denied deployment and the
RequestDisallowedByPolicyerror, then create an exemption for one RG.
Expected outcome / acceptance criteria: Compliance report lists non-compliant RGs; the custom deny works; the exempted RG allows the deployment.
Hints
Field alias: Microsoft.Storage/storageAccounts/allowBlobPublicAccess. az policy definition create --rules @rule.json --mode Indexed, az policy assignment create, az policy state summarize, az policy exemption create --exemption-category Waiver.
Bonus: Assign a DeployIfNotExists policy that adds diagnostic settings to Key Vaults and run a remediation task.
๐ด Advanced
Assignment 21. End-to-end AKS platform in Terraform with a secretless pipeline ๐ด
Objective: Reproduce the hands-on lab as reusable modules with two environments.
Tasks
- Split the lab into modules (
network,aks,acr,keyvault,monitoring,identity) with input validation. - Create
envs/devandenvs/prodroots with separate state keys and different sizes (FreevsStandardtier, node counts). - Build a pipeline: PR โ fmt, validate, tflint, Checkov, plan posted as a comment; merge โ apply dev automatically, prod after approval using the saved plan.
- Use separate federated identities for dev and prod applies.
Expected outcome / acceptance criteria: Both environments deploy from the same modules; a PR shows the plan; prod apply waits for approval and applies exactly the reviewed plan file.
Hints
Upload tfplan as an artifact between jobs. terraform show -no-color tfplan for the PR comment. In GitHub, environments infra-dev and infra-prod with separate federated subjects. Pin module versions with git tags.
Bonus: Add a nightly drift detection workflow that opens an issue when plan -detailed-exitcode returns 2.
Assignment 22. Private AKS with controlled egress ๐ด
Objective: Run a private cluster whose only egress is through Azure Firewall.
Tasks
- Build a hub with Azure Firewall (DNS proxy on) and a spoke with the AKS subnet and a route table
0.0.0.0/0โ firewall. - Allow the AKS required egress using the
AzureKubernetesServiceFQDN tag plus your ACR and MCR FQDNs, NTP, and the API server. - Create a private AKS cluster with
--outbound-type userDefinedRouting, Premium ACR with a Private Endpoint, and Key Vault with a Private Endpoint. - Deploy a workload using
az aks command invoke(no direct API access) and show a pod cannotcurl https://example.com.
Expected outcome / acceptance criteria: Cluster provisions successfully; firewall logs show allowed AKS dependencies and denied example.com; images pull through the private endpoint.
Hints
Create the route table and firewall rules before the cluster, or creation fails while nodes try to bootstrap. Private DNS: privatelink.<region>.azmk8s.io (system-managed is fine), privatelink.azurecr.io, privatelink.vaultcore.azure.net. Use --enable-private-cluster --vnet-subnet-id.
Bonus: Add an internal Application Gateway for Containers or app routing with an internal load balancer, and expose the app only to the hub.
Assignment 23. Zero-downtime AKS upgrade under load ๐ด
Objective: Upgrade an AKS cluster by one minor version while proving no user-visible errors.
Tasks
- Deploy an app with 4 replicas, readiness probes, a PDB (
maxUnavailable: 1) and topology spread across zones. - Run a load generator (k6, hey or a curl loop) recording status codes for the whole upgrade.
- Upgrade the control plane, then the node pool with
--max-surge 33%,--node-soak-duration, and an explicit drain timeout. - Repeat with a broken PDB (
maxUnavailable: 0) and capture the failure and recovery.
Expected outcome / acceptance criteria: First upgrade: zero non-2xx responses; second: UpgradeFailed with the PDB message, fixed by relaxing the PDB and resuming.
Hints
az aks get-upgrades, az aks upgrade --control-plane-only, az aks nodepool upgrade --max-surge 33% --drain-timeout 30 --node-soak-duration 2. Make sure you have quota for surge nodes first.
Bonus: Configure auto-upgrade channels with a weekly maintenance window and show the schedule with az aks maintenanceconfiguration list.
Assignment 24. Multi-region active-passive with Front Door ๐ด
Objective: Design and test regional failover for a web app.
Tasks
- Deploy the same app (App Service or AKS) in
centralindiaandsouthindiafrom one IaC codebase. - Put Front Door Standard in front with priority routing and health probes on
/healthz. - Use geo-replicated data (Azure SQL failover group, or GZRS storage for a static workload).
- Simulate a primary region outage (stop the app or make
/healthzreturn 500), measure RTO, then fail back.
Expected outcome / acceptance criteria: A written runbook with measured RTO, the observed RPO for the data tier, and Front Door logs showing the origin switch.
Hints
az afd profile create, az afd origin-group create --probe-path /healthz, az afd origin create --priority 1/2. Lock origins to Front Door with the AzureFrontDoor.Backend service tag and an X-Azure-FDID header check.
Bonus: Make it active-active with weighted routing and explain what changes in the data tier.
Assignment 25. FinOps and governance review of a messy subscription ๐ด
Objective: Act as the platform engineer brought in to clean up an existing subscription.
Tasks
- Using Resource Graph, produce an inventory: untagged resources, unattached disks, unused public IPs, stopped-but-allocated VMs, empty App Service plans.
- Query Cost Management for the top 10 cost drivers for the last 30 days and the Log Analytics ingestion by table.
- Implement fixes: tag inheritance policy and remediation, delete waste, a daily cap on non-prod workspaces, auto-shutdown on dev VMs.
- Write a one-page report with before/after monthly cost and the policies added.
Expected outcome / acceptance criteria: Report with numbers, the KQL and CLI used, and a policy compliance screenshot showing improvement.
Hints
Unattached disks: Resources | where type =~ 'microsoft.compute/disks' and properties.diskState == 'Unattached'. Unused public IPs: Resources | where type =~ 'microsoft.network/publicipaddresses' and isnull(properties.ipConfiguration). Log Analytics: Usage | summarize sum(Quantity) by DataType. az costmanagement query or exports for cost data.
Bonus: Set up a scheduled Cost Management export to storage and a budget per resource group with an action group that posts to a Teams or Slack webhook.