Skip to content

Tear down (T+2)

Who: each member, then the team lead, then the named admin for each repo. When: T+2, after the event owner’s approval.

Run commands from ~/src/<your-repo>/factory in Azure Cloud Shell, not from vm-dev01: member removal deletes that VM. Members remove their own scopes first; the team lead’s full run then verifies/removes every member scope before removing the foundation.

See Cost for when the foundation, datacenter and archetype charges stop.

  • On vm-dev01, git -C C:\src\<your-repo> status is clean and all commits on main (app modernization, archetype outputs, C9 scripts, and factory/evidence/ deliverables) are pushed to GitHub; verify the commits on GitHub.
  • You have privately saved your settings values (subscription, member index, suffix, location) and the agreed return management group. Never commit them.
  • The event owner has approved removal, named each repo’s finalizer admin and decided whether the tenant will be reused.

Allow time: about 20 minutes without an archetype, but up to about 2 hours with SQL MI, followed by team cleanup. MI deletion and subnet release can keep the run busy for a long time. Do not cancel it because it looks idle; read the job log and Troubleshooting.

When: At T+2, from ~/src/<your-repo>/factory in Azure Cloud Shell, in this exact order:

  1. First — each team member (indexes 2..n, in their own repo): removes only that member’s datacenter, spoke, and archetype:

    Terminal window
    gh workflow run platform.yml -f stage=teardown
  2. Second — the team lead (in the team lead’s repo, at T+2): once members have torn down (or to sweep all 1..n member scopes including the team lead’s own slot 1 and then delete the shared foundation), run:

    Terminal window
    gh workflow run platform.yml -f stage=teardown -f members=all -f confirm-team-teardown=true -f include-management=true

    Omit -f include-management=true only when the event owner will reuse rg-management (id-sqlmi-directory) in the same tenant. If your roster has more than 256 members, remove members in sequential batches first (-f stage=teardown -f members=1-250, wait for green, then -f stage=teardown -f members=251-300, wait for green), and finally remove the foundation with -f stage=teardown -f members=none -f confirm-team-teardown=true -f include-management=true.

Recovering a single member slot before T+2 (team lead only)

Never run -f members=all or -f confirm-team-teardown=true before T+2. To tear down a single member’s subscription before C5 from the team lead’s repo, pass only that member’s index:

Terminal window
gh workflow run platform.yml -f stage=teardown -f members=<index>

Done when the run is green and the resource checks below pass. If a member fails, team cleanup does not proceed; fix the cause and rerun the same stage. Never force-remove an MI subnet association.

The workflow cannot remove its own identity. Each member is the admin for their own repo, or the event owner names a replacement with repo-admin rights and Owner wherever that pipeline’s roles were granted. The team lead (or the named event admin) finalizes the lead repo with repo-admin rights, Owner at Tenant Root (or the configured parent) and access to the shared subscription. Keep those permissions until finalization is verified.

In each repo, sign in with gh auth login and az login --tenant '<tenant-id>' as that admin, then run the command matching your role from factory/ (it removes the pipeline roles, managed identity, rg-cicd, gh-lab environment, and pipeline variables, and verifies each is gone):

  • If you are a team member (indexes 2..n, in your own repo):

    Terminal window
    ./scripts/Remove-PlatformPipeline.ps1 -Profile Member
  • If you are the team lead (in your team-lead repo):

    Terminal window
    ./scripts/Remove-PlatformPipeline.ps1

Done when the script reports every item as gone.

For each workload subscription, load your own settings and check the exact kit groups:

Terminal window
$s = Get-Content .local/settings.json | ConvertFrom-Json
az group exists --subscription $s.subscriptionId --name rg-datacenter
az group exists --subscription $s.subscriptionId --name rg-spoke
az group exists --subscription $s.subscriptionId --name "rg-university-$($s.suffix)"
az group exists --subscription $s.subscriptionId --name rg-cicd

Each result must be false. The team lead also checks rg-hub, the kit management groups, subscription return placement, Arc entries, budgets, policy artifacts and kit-created role assignments, and has the Entra group owner or directory admin delete <mgPrefix>-readers (or clear its membership for approved tenant reuse). Check rg-management is gone unless reuse was explicitly agreed. Group checks alone do not prove every subscription-level artifact is gone.

Keep the finalizer’s verification result. Only then remove temporary human access (Tenant Root Owner, elevation, directory-role activation and repo collaborators) with the person who granted it. See Troubleshooting if cleanup stops.

  • With the recommended include-management=true, deleting id-sqlmi-directory removes its Graph grants. If the owner explicitly reuses the tenant and omits that input, the identity/grants remain; a later event needs the grant again after deletion.
  • Repos, evidence and subscriptions remain. Agree retention with the partner.
  • Cleanup removes vending-created roles, not pre-existing human access; the person who granted it removes the latter after pipeline finalization.