The bundled role map and alias snapshot are refreshed weekly from a sandbox, signed in by OIDC, through a reviewed pull request¶
Context and Problem Statement¶
The module bundles every built-in role (src/Data/roles.json, ADR-0022) and every resource type's aliases (src/Data/aliases.json, ADR-0008), so real policies build without a refresh and converted ones name their roles. Azure adds roles and aliases often, and occasionally renames or removes them. Update-BylawRoleCache and Update-BylawAliasCache fetch the current data, but they need a signed-in Azure account, so they have been run by hand. How should the bundled data stay current, without putting the maintainer's credentials anywhere?
Decision Drivers¶
- The data in each release is current, without depending on someone remembering to refresh it.
- No password, client secret or personal sign-in stored anywhere, and nothing another repository, fork or branch could use.
- No cost, and no change to the Azure subscription.
- No tenant or subscription ID in the repository, the module or a log.
- A person sees what changed, and what it does to real policies, before it ships.
Considered Options¶
- A weekly workflow, signed in by GitHub's OIDC federation to an Entra app with Reader on the maintainer's sandbox subscription, that opens a pull request
- The same workflow with a client secret
- Refreshing by hand before each release
Decision Outcome¶
Chosen option: "A weekly workflow, signed in by OIDC, that opens a pull request".
- The workflow is
.github/workflows/data-refresh.yml. It runs every Monday, and by hand from the Actions tab. It signs in withazure/login, then runsbuild/data/Sync-BylawData.ps1, which: - runs
Update-BylawRoleCacheandUpdate-BylawAliasCacheintoout/data-refresh; - stops if either file holds the signed-in tenant or subscription ID, without repeating the ID;
- compares the files with
src/Data, leaving outgeneratedAt, so a run that finds only a new date changes nothing; - applies only additions: new roles, types and aliases, and metadata gained, such as the modifiable flag. What the run no longer sees, a removed role, type or alias or lost metadata, is kept and listed under "Not applied" for a person to check, and
-AllowRemovalapplies it (added 2026-11-30, below); - when something changed, copies them into
src/Data, re-converts the pinned Azure Landing Zones Library copy (ADR-0042), so the effect on real policies shows, and updates the README's coverage totals; - writes the pull request description: roles added, removed, renamed and given another GUID; resource types and aliases added and removed; aliases whose metadata, such as the modifiable flag, changed; and any ALZ status that changed.
- The pull request comes from one
data/refreshbranch, replaced each run, so only one is ever open. The workflow starts CI on it, since a pull request opened with the workflow token doesn't start other workflows. Nothing is merged automatically. - Sign-in: an Entra app registration in the maintainer's sandbox tenant, with a federated credential whose subject is
repo:markwragg@6706196/PowerShell-Bylaw@1471870191:ref:refs/heads/main. The repository uses GitHub's immutable subject claims, which name the owner and repository by ID as well as by name, so a renamed or transferred repository keeps its credential, and nobody who later takes the old name can use it. (gh api repos/<owner>/<repo>/actions/oidc/customization/subshows the prefix.) Scheduled and manual runs start frommain, so both match, and no other branch, fork or repository can sign in. There is no password or client secret. Deleting the app registration removes all access. - Access: Reader on the sandbox subscription only, which covers
Get-AzRoleDefinitionandGet-AzPolicyAlias. Nothing is created or changed, so it costs nothing: app registrations, federated credentials and read calls are free, and Actions minutes are free for a public repository. - Privacy: the client, tenant and subscription IDs are repository secrets,
AZURE_CLIENT_ID,AZURE_TENANT_IDandAZURE_SUBSCRIPTION_ID, masked in logs and never committed. The files hold built-in role names and GUIDs and alias metadata, which are the same in every tenant, and the check above makes sure. - Releases: fresh data reaches users when it is released, so a pending refresh pull request is merged before a release, or a release is made for the data alone.
- Locally:
Connect-AzAccount, then./build/data/Sync-BylawData.ps1, does the same without opening a pull request.
Only additions are applied¶
Added 2026-11-30, after the first run. Run from a GitHub runner in the US, the refresh found 5 types and 211 aliases that the same sandbox didn't return from the UK half an hour earlier, and 8 aliases that had lost their modifiable flag and type. Azure rolls resource provider changes out region by region, and a runner reaches whichever region is nearest, so one week's data can be ahead of or behind the last. Applied as they come, the files would swing between rollouts in alternate pull requests.
So a refresh applies only what is new, which is right whichever region is ahead: a role, type or alias Bylaw knows a little before every region has it does no harm. A removal or lost flag is listed instead, because applying one that was only a region behind would make Bylaw reject a field that is valid, which is worse than accepting, until a person checks, one that Azure has really removed, which fails when the policy is deployed. ./build/data/Sync-BylawData.ps1 -AllowRemoval applies them once checked.
Consequences¶
- Good, because the data stays current, reviewed, and costs nothing, with no secret to leak or rotate.
- Good, because the ALZ re-conversion shows whether a change in Azure's data changes a real policy.
- Neutral, because the workflow depends on the maintainer's sandbox tenant. If it goes away, the workflow fails visibly, and the commands still work by hand.
- Bad, because a renamed or removed role or alias can break a policy that names it. The pull request lists them, and CI shows a broken example or golden test, but authors' own policies only find out when they build with the new release.
Confirmation¶
Unit tests cover the comparisons, including that generatedAt alone is no change, and the privacy check. Sync-BylawData.ps1 was run against the sandbox before the workflow was added: once with current data, finding no change, and once with a role removed from src/Data, opening the expected description.
Pros and Cons of the Options¶
OIDC federation, with a pull request¶
- Good, because there is no stored credential, and the credential works only for this repository's
main. - Bad, because it needs a one-time setup in Entra by the maintainer.
A client secret¶
- Good, because it is a familiar setup.
- Bad, because the secret can leak, must be rotated before it expires, and works from anywhere it is copied to.
By hand before each release¶
- Good, because it needs nothing new.
- Bad, because it depends on remembering, and a release can ship with data months old.
More Information¶
- Use GitHub Actions to connect to Azure, with OpenID Connect
- ADR-0008 (alias snapshot), ADR-0022 (role map), ADR-0042 (ALZ coverage and its weekly sync, which this follows).