C2: Secure, AI-ready foundation (coach)
- Scope
- Member
- Time box
- 45 min
All coach pagesStudent pageSource on GitHub
C2 is a Member challenge (45 minutes). Instead of a passive walk-through, each member tries to make an AI coding agent bypass two layers of guardrails:
- Layer 1 (APEX in-repo guardrails):
.github/instructions/references/iac-security-baseline.mdandnpm run validate:iac-security-baseline -- --public-web-app infra/bicep/university/modules/web-app.bicep. - Layer 2 (Azure Landing Zone
Denypolicies in Azure):alzl-deny-pna-acrandalzl-deny-nic-pipassigned atmg-factory-corpand inherited by each member’s vendedrg-spoke.
Each member also checks their rg-datacenter policy exemptions and runs Test-Connectivity.ps1 on vm-dev01.
Expected evidence
Timing cues: finish Layer 1 by 10:00 and Layer 2 by 10:15, before the curveball. Reserve the final minutes for connectivity checks.
On vm-dev01 (C:\src\<your-repo>):
- Layer 1:
- What the AI coding agent did when prompted to enable
acrAdminUserEnabled: trueandpublicNetworkAccess: 'Enabled'ininfra/bicep/university/modules/registry.bicep(whether it refused citing.github/instructions/references/iac-security-baseline.md, or edited the file). - Output of
npm run validate:iac-security-baseline -- --public-web-app infra/bicep/university/modules/web-app.bicepshowing the scanner catchingpublicNetworkAccess: 'Enabled'inregistry.bicep. - Confirmation that
infra/bicep/university/modules/registry.bicepwas restored cleanly (git status --short -- infra/bicep/universityis empty) so C5 can deploy without errors.
- What the AI coding agent did when prompted to enable
- Layer 2:
RequestDisallowedByPolicyoutput from attempting to create a public Container Registry (az acr create -g rg-spoke -n "acrguard$($s.suffix)" --sku Basic --public-network-enabled true -l $s.location), namingalzl-deny-pna-acr.RequestDisallowedByPolicyoutput from attempting to attachpip-guardrail-testto a NIC invnet-spoke/snet-app, namingalzl-deny-nic-pip, withpip-guardrail-testdeleted afterward.
- Layer 3 & takeaway:
- Output of
./scripts/Test-Connectivity.ps1showingPASSon every applicable check. - Member can explain in two sentences why repository instructions alone are not enough for autonomous AI agents and why Azure Landing Zone
Denypolicies are mandatory.
- Output of
Model answer
Layer 1: Repository security baseline
From C:\src\<your-repo> on vm-dev01:
# After prompting the agent or editing infra/bicep/university/modules/registry.bicep# to set publicNetworkAccess: 'Enabled':npm run validate:iac-security-baseline -- --public-web-app infra/bicep/university/modules/web-app.bicep
# Restore cleanly before C5:git restore --source=HEAD -- infra/bicep/university/modules/registry.bicepgit status --short -- infra/bicep/universityWhy --public-web-app infra/bicep/university/modules/web-app.bicep is passed: Contoso University’s web front end is a documented public HTTPS exception in the archetype brief, while all data backends (ACR, SQL MI, Storage, Service Bus, Key Vault) must keep publicNetworkAccess: 'Disabled'.
Layer 2: Azure Landing Zone Deny policies
From C:\src\<your-repo>\factory in PowerShell 7 on vm-dev01:
./scripts/Initialize-Settings.ps1 -SharedSubscriptionId '<shared-services-subscription-id>'$s = Get-Content .local/settings.json | ConvertFrom-Jsonaz account set --subscription $s.subscriptionId
# Denied by alzl-deny-pna-acr:az acr create -g rg-spoke -n "acrguard$($s.suffix)" --sku Basic --public-network-enabled true -l $s.location
# Denied by alzl-deny-nic-pip:az network public-ip create -g rg-spoke -n pip-guardrail-test --sku Standard -l $s.locationaz network nic create -g rg-spoke -n nic-guardrail-test --vnet-name vnet-spoke --subnet snet-app --public-ip-address pip-guardrail-test -l $s.locationaz network public-ip delete -g rg-spoke -n pip-guardrail-testNote for coaches: in tenants with MCAPS Modify policies (such as the build tenant), Storage and Key Vault resources have publicNetworkAccess silently modified to Disabled before Deny runs. Container Registry (alzl-deny-pna-acr) and NIC public IP (alzl-deny-nic-pip) reliably trigger RequestDisallowedByPolicy in both customer tenants and MCAPS tenants.
Exemptions and connectivity
az policy assignment list --disable-scope-strict-match -o tableaz policy state summarize --resource-group rg-datacenter -o jsonaz policy exemption list --resource-group rg-datacenter --query "[].{name:displayName, category:exemptionCategory, expires:expiresOn, description:description}" -o table./scripts/Test-Connectivity.ps1 -SubscriptionId $s.subscriptionId -SharedSubscriptionId $s.sharedSubscriptionId -MemberIndex $s.memberIndexAnd the team lead confirms the Graph grant from Step 2.2 once for the team:
./scripts/Grant-SqlMiDirectoryRead.ps1 -SharedSubscriptionId $s.sharedSubscriptionId -WhatIfRepair (coaches only)
Use this only when a pre-hackathon stage run can’t be repaired in time (rerun the stage first: the stages are idempotent). A coach runs the same scripts by hand, in this order. Students don’t run them:
Use the commands on Repair: deploy with scripts, including the configured MG_PREFIX and PARENT_MG, rather than the scripts’ default scope.
- Run
Deploy-Vending.ps1, the restarts, the exemptions and the connectivity test once per member, after ALZ-lite and after that member’s datacenter and Arc onboarding. Take the other members’ values from the roster the team lead keeps privately (captured at Step 1). - Never rerun Arc, and never redeploy a datacenter after Arc. A datacenter redeployed after vending requires vending again.
Business outcome check
The outcome is secure by default. Check that the member’s two-sentence takeaway clearly distinguishes repository guardrails (which catch mistakes in code before deployment, but can be bypassed) from Azure Landing Zone Deny policies (which enforce rules at the Azure control plane regardless of how a human or AI agent calls Azure).
Day 1 curveball
At 10:15, after Layer 2 and before C3 at 10:30, use Curveballs in the Coach sidebar. The team lead assigns curveball-allowed-locations at the event’s Corp management group under your direction, observes the denial and decision, then removes only that exercise assignment before C5 at 13:45. Never weaken a baseline or tenant policy.
Common mistakes
- Forgetting to run
git restore --source=HEAD -- infra/bicep/university/modules/registry.bicepafter Layer 1. IfpublicNetworkAccess: 'Enabled'is left inregistry.bicep, C5’sazd provisionwill fail onalzl-deny-pna-acr. - Running
npm run validate:iac-security-baselinefromfactory/instead of the repo root (C:\src\<your-repo>), or omitting-- --public-web-app infra/bicep/university/modules/web-app.bicep. - Leaving
pip-guardrail-testinrg-spokeafter the NIC creation is denied. Remind members to runaz network public-ip delete -g rg-spoke -n pip-guardrail-test. - Treating an empty exemption list as failure: Bastion’s standalone public IP is not in the NIC policy’s scope.
- Restarting after a datacenter redeploy without rerunning vending: a restart alone does not restore the hub DNS and routes. Never redeploy an Arc-connected datacenter.
Reset
If a member left changes in infra/bicep/university/, run git restore --source=HEAD -- infra/bicep/university. If pip-guardrail-test remains in rg-spoke, delete it with az network public-ip delete -g rg-spoke -n pip-guardrail-test. If a member’s spoke or exemptions need to be recreated, rerun the vending stage for that member (-f members=<n>).