Skip to content

Step 2: Foundation and Graph grant (T-7)

Who: Team lead + Privileged Role Administrator (or Global Administrator). Students have nothing to run in Step 2. When: By T-7 (7 days before day one). Allow 15 to 25 minutes for foundation plus 5 minutes for the Graph grant; see the stage timing table.

In Step 2, the team lead deploys the shared landing zone (ALZ-lite) once for the entire cohort from <event>-lead, then a Privileged Role Administrator grants Microsoft Graph directory-read permissions to id-sqlmi-directory. Run 2.1 from factory/ in <event>-lead; the administrator can run 2.2 from any machine without cloning the repository.

Two stages. The foundation stage, once per team, builds the management groups, the shared hub with firewall, private DNS and policies, and the shared SQL Managed Instance directory identity, then waits for a person to grant Graph read permissions. The vending stage, once per member, places the member's subscription under the factory group, builds the spoke network, peers it to the hub, adds routes, DNS and firewall rules, applies RBAC and a budget, and records datacenter policy exemptions.
Step 2 deploys the shared foundation once for the cohort. Step 4 (vending) connects all n student subscriptions to it at T-1. Open full size

When: At T-7, after Step 1 is complete—including a green whatif preflight run—and .local/roster.json is registered in <event>-lead via Initialize-PlatformPipeline.ps1 -RosterPath .local/roster.json.

Before dispatching foundation, have an authorized Entra operator bootstrap the reader group. Foundation grants the group control-plane Reader at the kit management group and all its descendants, including every vended workload subscription. It grants no Tenant Root or data-plane access. This is separate from the SQL MI Graph grant below.

From factory/ in <event>-lead, dispatch foundation:

Terminal window
gh workflow run platform.yml -f stage=foundation

(Only if you updated .local/roster.json since Step 1, sync secrets with ./scripts/Initialize-PlatformPipeline.ps1 -RosterPath .local/roster.json and run gh workflow run platform.yml -f stage=whatif—batched as -f members=1-200, then -f members=201-300 above 256 members—waiting for whatif to finish green before dispatching foundation.)

foundation creates:

  • Management groups mg-factory, mg-factory-platform, and mg-factory-corp under Tenant Root, with core governance policies assigned at mg-factory-corp.
  • rg-management in the shared services subscription containing log-management and the user-assigned managed identity id-sqlmi-directory.
  • rg-hub in the shared services subscription containing vnet-hub, Azure Firewall (afw-hub / afwp-hub), and Private DNS zones.

Open the Actions tab on <event>-lead and approve the run if prompted. Done when foundation is green.

2.2 Grant Microsoft Graph read permissions

Section titled “2.2 Grant Microsoft Graph read permissions”

Every student’s SQL Managed Instance uses id-sqlmi-directory in C7 so CREATE USER ... FROM EXTERNAL PROVIDER can resolve Microsoft Entra principals. This grant runs once per cohort after foundation completes and must be in place before Day 2 (C7).

Have someone holding Privileged Role Administrator (or Global Administrator) in the event tenant run Grant-SqlMiDirectoryRead.ps1 and verify with -WhatIf:

Terminal window
./scripts/Grant-SqlMiDirectoryRead.ps1 -SharedSubscriptionId '<shared-services-subscription-id>'
./scripts/Grant-SqlMiDirectoryRead.ps1 -SharedSubscriptionId '<shared-services-subscription-id>' -WhatIf
Standalone commands for a Privileged Role Administrator without the repo

The administrator does not need access to <event>-lead. On any computer with PowerShell 7.4 or later, Azure CLI, and Reader on the shared services subscription, activate Privileged Role Administrator in PIM if needed, sign in to the event tenant, and run:

Terminal window
az login --tenant '<tenant-id>'
Invoke-WebRequest -Uri 'https://raw.githubusercontent.com/jonathan-vella/apex-factory-hackathon/main/scripts/Grant-SqlMiDirectoryRead.ps1' -OutFile Grant-SqlMiDirectoryRead.ps1
./Grant-SqlMiDirectoryRead.ps1 -SharedSubscriptionId '<shared-services-subscription-id>'
./Grant-SqlMiDirectoryRead.ps1 -SharedSubscriptionId '<shared-services-subscription-id>' -WhatIf

The -WhatIf verification must report all three Microsoft Graph application permissions (User.Read.All, GroupMember.Read.All, and Application.Read.All) as already granted. If the command stops with InteractionRequired or TokenCreatedWithOutdatedPolicies, run az logout, sign in again with az login --tenant '<tenant-id>', and repeat. See the ALZ-lite guide for background.

Done when -WhatIf confirms all three Microsoft Graph permissions are granted on id-sqlmi-directory.

Inspect the failed job in <event>-lead under Actions, resolve the root cause, and re-run gh workflow run platform.yml -f stage=foundation. The foundation stage is idempotent and safe to repeat. Check Troubleshooting for common policy and permission errors.

Next: Step 3: Datacenters and Arc (T-3).