Skip to content

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

Path: Path A: Self-service teams (in a lead-provisioned cohort, follow Step 2: Foundation and Graph grant (Lead-provisioned) instead). Who: Team lead (books the role holder) + Privileged Role Administrator. (Members have nothing to run in Step 2; skip to Step 3: Datacenter and workstation (T-3).) When: By T-7 (7 days before day one). See the stage timing table.

In Step 2, the team lead deploys the team’s shared foundation (ALZ-lite) once for the whole team, then books a Privileged Role Administrator (or Global Administrator) to grant its SQL Managed Instance identity Microsoft Graph read permissions. If no role holder is available, escalate to the event owner. The factory/ working-directory instruction applies to 2.1; the administrator can run 2.2 independently.

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 builds the shared foundation once for the team. Step 4 (vending) connects each member's subscription to it at T-1. Open full size

2.1 Deploy the foundation stage (Team lead)

Section titled “2.1 Deploy the foundation stage (Team lead)”

When: At T-7, after Step 1 is complete—including a green whatif preflight run—.local/roster.json is registered with Initialize-PlatformPipeline.ps1 -RosterPath .local/roster.json, and your account holds Owner at Tenant Root plus Owner on the shared services subscription.

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.

Foundation creates the management groups (mg-factory, mg-factory-platform, mg-factory-corp), rg-management (log-management and id-sqlmi-directory), and rg-hub (Azure Firewall, Private DNS, and policies). Run from ~/src/<your-repo>/factory in Azure Cloud Shell:

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

(Only if you edited .local/roster.json since Step 1, run ./scripts/Initialize-PlatformPipeline.ps1 -RosterPath .local/roster.json and gh workflow run platform.yml -f stage=whatif first, and wait for whatif to finish green before running foundation.)

Open the Actions tab on GitHub and approve the foundation run if asked. Done when the run is green.

2.2 Grant Microsoft Graph read permissions (Privileged Role Administrator)

Section titled “2.2 Grant Microsoft Graph read permissions (Privileged Role Administrator)”

ALZ-lite creates the user-assigned managed identity id-sqlmi-directory in rg-management. Every member’s SQL Managed Instance uses this identity in C7 so CREATE USER ... FROM EXTERNAL PROVIDER can resolve Microsoft Entra principals.

The team lead books someone holding the Privileged Role Administrator (or Global Administrator) directory role in your tenant to run Grant-SqlMiDirectoryRead.ps1 once for the team, right after 2.1 completes. If they cannot find a role holder, they escalate to the event owner:

Terminal window
./scripts/Grant-SqlMiDirectoryRead.ps1 -SharedSubscriptionId '<shared-services-subscription-id>'
What to send the Privileged Role Administrator

They do not need your repository. On their own computer, they need PowerShell 7.4 or later, Azure CLI and Reader on the shared services subscription. First activate Privileged Role Administrator through PIM if eligible, then sign in as themselves to the event tenant. The team lead supplies the two IDs privately. Run the standalone script (no kit dependencies):

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

For an event copy, use the script URL the event owner supplies. The final read-only check must report all three permissions already granted.

If it stops with InteractionRequired or TokenCreatedWithOutdatedPolicies, their sign-in is stale: they run az logout and az login again, then repeat. To verify that the three permissions (User.Read.All, GroupMember.Read.All, Application.Read.All) are in place without changing anything, run the script with -WhatIf. See the ALZ-lite guide for details.

Done when the administrator confirms the script finished (or -WhatIf reports all three permissions as already granted).

Read the run log in the Actions tab, fix the cause, and run the stage again: foundation is idempotent and safe to repeat. Troubleshooting lists the common errors.

Next: everyone (the team lead included) runs Step 3: Datacenter and workstation (T-3).