Deploy with scripts (coach)
All coach pagesSource on GitHub
This page is the coach’s repair path, only when an Actions run can’t be repaired in time. Rerun or repair the stage first. The kit’s scripts are the engine the pipeline stages run, not an alternative attendee deployment path. The pipeline itself is described in the platform pipeline page.
There are two roles. Member is each member’s datacenter (n >= 1). Team lead (called the platform lead in the workflow and scripts) deploys the foundation and vends every member, is also a member on index 1, and in Path B (Lead-provisioned cohort) also provisions the student repositories (Initialize-CohortRepos.ps1) and runs the member and teardown stages across the cohort. The Readiness check and C2 hold the checks and the hints. This page is the short sequence.
Use PowerShell in Azure Cloud Shell for these repairs. Open the relevant lead or member repo’s factory/ folder and confirm the Azure sign-in and subscription before running anything. In each new terminal, load the settings for the environment you are repairing:
$s = Get-Content .local/settings.json | ConvertFrom-Json$mgPrefix = '<MG_PREFIX from the repo gh-lab variables>'$parentMg = '<PARENT_MG from the repo gh-lab variables>'Read MG_PREFIX and PARENT_MG in the repository’s gh-lab environment variables. Set $parentMg = '' only when PARENT_MG is empty (Tenant Root). Never substitute a guessed scope.
The order matters
The team lead’s sequence: T-7 Deploy-AlzLite.ps1, then the Graph grant (a person), then T-1 Deploy-Vending.ps1, then the VM restarts, the exemptions and the connectivity probes.
Each member’s sequence, team lead included: Test-Preflight.ps1, Deploy-Datacenter.ps1, Test-Datacenter.ps1, Connect-DatacenterArc.ps1, then vm-dev01 setup and readiness evidence commit.
Vending needs both ALZ-lite and each member’s Arc-connected datacenter (Invoke-PipelineVending.ps1 checks vnet-datacenter and vm-app01’s Arc Connected status automatically).
- Run
Test-Datacenter.ps1before Arc: Arc turns off the guest agent the test relies on. - Never redeploy a datacenter after Arc, and never run the Arc script a second time.
- ALZ-lite and each member’s datacenter must exist before vending. The Graph grant comes after ALZ-lite and before C7.
Member
The deploy takes up to 60 minutes, unattended. Keep the terminal open and the computer awake.
-
Check the subscription. Fix every FAIL, then re-run with
-Fixto register providers:Terminal window ./scripts/Test-Preflight.ps1 -WorkloadSubscriptionId $s.subscriptionId -Location $s.location -OutFile .local/preflight.json -
Deploy the datacenter. It is safe to run again until Arc onboarding. For a member without eligible Windows Server licenses, add
-NoHybridBenefit:Terminal window ./scripts/Deploy-Datacenter.ps1 -SubscriptionId $s.subscriptionId -MemberIndex $s.memberIndex -Location $s.locationFor an event copy, also pass
-Repository '<event-owner/event-repo>' -ScriptsRef '<reviewed-commit-or-tag>'so the guest scripts come from the same reviewed copy. Outside a disposable lab, collect secure strings withRead-Host -AsSecureStringand pass-AdminPassword $adminPassword -SqlAppPassword $sqlAppPassword; never put passwords in a command, log or repo. Preserve the deployment’s original credentials on a repair. -
Confirm it is healthy. Every row must be PASS. Save the output as the evidence (add
-NoHybridBenefitfor a member without eligible licenses, or the license row fails):Terminal window ./scripts/Test-Datacenter.ps1 -SubscriptionId $s.subscriptionId -MemberIndex $s.memberIndex -
Onboard
vm-app01to Azure Arc. Don’t run it again if it times out after it started:Terminal window ./scripts/Connect-DatacenterArc.ps1 -SubscriptionId $s.subscriptionId -MemberIndex $s.memberIndex -Location $s.location -
The member does the steps only a person can: the Arc migration assessment in the portal and the
vm-dev01setup. A hand-run deploy writes.local/<subscription-id>/datacenter.jsonitself, soGet-PipelineEvidence.ps1isn’t needed.
Team lead
The team lead needs Owner at the configured parent management group (Tenant Root when no parent is set), access to the shared services subscription in .local/settings.json, and the roster values captured for every member.
-
At T-7, bootstrap the reader group, obtain its object ID privately, then deploy the foundation. It takes about 15 to 25 minutes, mostly Azure Firewall, and bills about $1.30 an hour until the event is cleaned up:
Terminal window az account set --subscription $s.sharedSubscriptionId./scripts/Deploy-AlzLite.ps1 -SharedSubscriptionId $s.sharedSubscriptionId -Location $s.location -MgPrefix $mgPrefix -ParentManagementGroupId $parentMg -ReaderGroupId '<reader-group-id>' -WhatIf./scripts/Deploy-AlzLite.ps1 -SharedSubscriptionId $s.sharedSubscriptionId -Location $s.location -MgPrefix $mgPrefix -ParentManagementGroupId $parentMg -ReaderGroupId '<reader-group-id>' -
Right after it, a Privileged Role Administrator grants the SQL MI identity its Graph read, once per team, from their own computer and signed in as themselves:
Terminal window ./scripts/Grant-SqlMiDirectoryRead.ps1 -SharedSubscriptionId '<shared-services-subscription-id>' -
The team lead does their own datacenter as a member, above.
-
At T-1, sync the full reader roster, then vend each member serially after confirming their Step 3 datacenter and Arc connection are complete. For a nested security group, add
-NestedReaderGroupand sign in to the event tenant as an authorized group owner with a process-scoped delegatedConnect-MgGraphsession andGroupMember.Read.All. Each run updates the same firewall policy and takes 4 to 5 minutes:Terminal window ./scripts/Deploy-Vending.ps1 -WorkloadSubscriptionId '<member-subscription-id>' -SharedSubscriptionId $s.sharedSubscriptionId -MemberIndex <member-index> -MemberPrincipalId '<member-object-id>' -ReaderGroupId '<reader-group-id>' -BudgetEmail '<member-email>' -Location $s.location -MgPrefix $mgPrefix -ParentManagementGroupId $parentMg -
For every member, restart both VMs, record the exemptions, then run the probes. Tell the member first: a restart ends their Bastion session.
Terminal window az vm restart -g rg-datacenter -n vm-dev01 --subscription '<member-subscription-id>'az vm restart -g rg-datacenter -n vm-app01 --subscription '<member-subscription-id>'./scripts/New-DatacenterExemptions.ps1 -SubscriptionId '<member-subscription-id>' -Owner '<member name>'./scripts/Test-Connectivity.ps1 -SubscriptionId '<member-subscription-id>' -SharedSubscriptionId $s.sharedSubscriptionId -MemberIndex <member-index>If the exemptions output says “nothing to do”, the policies haven’t taken effect yet (up to 30 minutes after ALZ-lite). Wait and run it again.
Never commit the member values (subscription ID, object ID, email) to any repo. The team lead takes them from the private roster.
If something breaks
The scripts are idempotent. Run the same command again to converge a failed or partial deployment. There is no -Force parameter. If a member’s datacenter is redeployed before Arc, the team lead vends that member again, restarts both VMs and records the exemptions again.
Taking it down
Use the teardown stage. By hand, run Remove-FactoryEnvironment.ps1 for every member scope first, then for the team scope (see cleanup). Deleting rg-hub stops the firewall’s cost but also breaks central DNS and connectivity for every vended spoke; it is not a pause switch. Recovery requires redeploying the foundation and rerunning vending for every member. Peerings, policy assignments, management groups and budgets can remain behind.