Skip to content

A conversion gallery of Azure's built-in policies, Community Policy and the ALZ library, generated at each release

Context and Problem Statement

Milestone 8's last item is a conversion gallery: real policy definitions shown beside the bylaw ConvertTo-Bylaw writes for them, so people can see how Bylaw reads policy they know, without installing it. ADR-0048 left it out of the documentation site's decision. What goes in it, where does it come from, how and when is it built, and where is it published? And can it leave room for people to share their own Bylaw files, as Azure Community Policy does for JSON?

Measured on 2026-12-01 with 0.8.0-alpha, on a 12-processor machine, converting every definition in Azure/azure-policy at commit ef6a0f9 (release 3.2026.1112.4) and in Azure/Community-Policy at commit ca75091:

Definitions Converted With Condition Doesn't convert
All built-in policies 5,226 3,166 1,743 317
All built-in initiatives 277 237 40
Public cloud policies, without placeholders 2,911 2,634 (90%) 72 (2%) 205 (7%)
Public cloud initiatives 194 160 (82%) 34 (18%)
Azure Landing Zones Library (tests/Alz) 193 192 1 0
Community Policy policies 591 482 (82%) 16 (3%) 93 (16%)
Community Policy initiatives 3 3 0
  • Azure Government copies: 1,566 of the files are in an Azure Government folder, mostly copies of public cloud definitions.
  • Placeholders: 1,664 policies (832 public, 832 Government) are "Microsoft Managed Control" placeholders for regulatory compliance initiatives. They have no mode, and their rule ends in { "value": "false", "equals": "true" }, so they never match. That literal comparison is why 1,664 of the 1,743 Condition results are there.
  • What doesn't convert, in public cloud:
  • 148 policies use a resource provider mode, such as Microsoft.Kubernetes.Data (77) or Microsoft.KeyVault.Data (25), which the language doesn't have yet (SPEC.md, Later).
  • 34 conversions don't compile (BYL6003). For example, BYL3007 rejects Microsoft's own guestConfiguration metadata as longer than 1,024 characters.
  • 57 don't prove equivalent (BYL6004), 31 of them initiatives, for example over a member parameter's allowedValues.
  • The last two groups are ConvertTo-Bylaw bugs, to be fixed separately. The gallery makes them visible.
  • What doesn't convert, in Community Policy: contributed definitions are less uniform than Microsoft's.
  • 29 have an effect parameter allowing an effect the policy can't use, such as Deny on a Modify policy (BYL3062, BYL3072).
  • 18 use a resource provider mode.
  • 18 are malformed: no policyRule, or an undeclared effect parameter.
  • A few use parameter properties Bylaw doesn't keep yet, such as minValue, maxValue and metadata.description.
  • Time and size:
  • Converting and proving all 5,503 took 26 minutes, with no definition stalling. The public cloud set is about half of it.
  • The converted files are 22.6 MB, for 40.2 MB of source JSON.
  • The ALZ library converts in about 26 seconds, and Community Policy in under 3 minutes.

Decision Drivers

  • Honest: it shows what doesn't convert, and why, beside what does. A gallery of successes only would mislead.
  • Current: it shows what the released ConvertTo-Bylaw writes, for a known version of the built-ins, and says which.
  • No server, and no new service: static files on the GitHub Pages site that already exists (ADR-0048).
  • Pull requests stay quick. A 26-minute conversion can't run on each one.
  • Findable and shareable: search and filters across thousands of definitions, and a stable link to each.
  • Built-in policies are Microsoft's, under the MIT licence: the notice goes with every copy, as for ALZ (ADR-0042).
  • Policy text is third-party data. It is shown as text, never run, never interpreted as HTML.

Considered Options

  • A static gallery at the site's root, generated at each release from pinned commits of its sources
  • Gallery pages inside each version of the documentation site
  • The converted built-ins committed to the repository, as the ALZ files are

Decision Outcome

Chosen option: "A static gallery at the site's root, generated at each release". The gallery shows what the newest release does, so it doesn't need a copy per documentation version. Generating it only at release keeps pull requests quick, and the pinned commits make each gallery reproducible.

Sources

  • Built-ins:
  • Azure/azure-policy's built-in-policies folder, at a commit pinned in build/gallery/sources.psd1.
  • The build fetches that commit's files through the GitHub API, as ADR-0042 does for ALZ, without cloning.
  • It stops if the repository's licence is no longer MIT.
  • Community Policy: Azure/Community-Policy's policyDefinitions and policySetDefinitions, at a commit pinned in the same file, fetched and licence-checked the same way. Its two-level layout, a folder per definition with the full azurepolicy.json beside the split rules and parameters files, is one ConvertTo-Bylaw already reads (0.5.0-alpha).
  • ALZ: the pinned copy in tests/Alz, under its own notice. No second copy.
  • Moving the pins: a weekly workflow moves the built-ins and Community Policy pins to their latest commits, through a pull request whose description has the change in the gallery's totals, as alz-sync.yml does. The new pins are published with the next release.

What is in it

  • Public cloud definitions only. The Azure Government copies are left out, which the coverage page says, with their number.
  • The Microsoft Managed Control placeholders are left out of the listing. They make up a third of the policies, and they show nothing about converting real policy. The coverage page counts them separately and says why.
  • Every other definition has an entry, whatever its status, including preview and deprecated ones, which are badged and can be filtered.

Pages

  • An entry per definition, at /gallery/builtin/<name>/, /gallery/community/<folder>/ or /gallery/alz/<name>/. Built-ins and Community Policy definitions are named by GUID, so the page title is the display name, and a Community Policy entry's address uses its folder name, which the repository already makes readable and unique. Each entry has:
  • Its display name, description, category, effects, mode, version, and preview or deprecated state.
  • A status:
    • Converted.
    • Uses Condition, with the raw conditions marked in the bylaw.
    • Doesn't convert yet, with the reason, the diagnostic's code and its link to the documentation (ADR-0048).
  • The source JSON beside the bylaw, coloured by the landing page's highlighters, with their line counts. For a DeployIfNotExists, the template files are listed too.
  • The source file's link at the pinned commit. An initiative lists its members, each linking to its own entry.
  • The index, /gallery/, has client-side search and filters:
  • Search: name, display name and description.
  • Filters: source, category, effect, mode, status, preview and deprecated.
  • It is one page and a compact index.json. Without JavaScript, it lists the categories, each a static page of links, so every entry is reachable and indexable.
  • A coverage page: totals by source, status and category, and what doesn't convert grouped by reason. It doubles as a public list of the language's gaps.
  • Provenance: every page says which release of Bylaw wrote it, and which commit of its source it read.
  • Licence: a notice page has the copyright and MIT licence of each source: the built-ins, Community Policy, and tests/Alz's notice for ALZ. Every entry links to it, and a Community Policy entry also links to the repository its author contributed to.

SPEC.md asked for "a diff". A diff between JSON and PowerShell lines up nothing, so the gallery shows the two side by side, with their line counts, instead.

Build and publishing

  • Generating it: ./build/build.ps1 -Task Gallery converts every source with the module being built, and writes the pages into out/gallery.
  • The pages are generated by PowerShell, like the landing page, not by Zensical. Thousands of pages would slow every documentation build, and would be copied into every version.
  • The pages use the landing page's look, and link to latest for the documentation.
  • Publishing: the release job publishes the gallery at gallery/ in the root of gh-pages, beside the landing page, when a version becomes latest. The manual "Documentation site" workflow can do it too.
  • It runs in its own job, after the release has published, so a slow or failed gallery never holds up a release.
  • It replaces the folder as a whole, so a removed definition doesn't linger.
  • Pull requests generate the gallery from the ALZ copy only, about 30 seconds, to check the generator. The full run, with the built-ins and Community Policy, is left to releases.
  • Git history: the output is deterministic (ADR-0009), so a release only adds the pages that changed to gh-pages' history; unchanged files are the same objects.

Room for contributed Bylaw files, later

The gallery's sources are a list in build/gallery/sources.psd1, each a pinned repository and folders, read the same way. A future source can be Bylaw files that people contribute because others would find them useful, as Community Policy collects JSON. Its entries would sit beside the others, at /gallery/contrib/<folder>/, with the JSON the build compiles them to on the left and the contributed bylaw on the right.

Accepting them is a separate decision, for when there is demand. It rests on these, which this design keeps open rather than decides:

  • Restricted mode first. A .bylaw.ps1 file is a PowerShell script, and building it runs it (ADR-0014). CI that builds strangers' files would run their code. Contributions can only be accepted once ADR-0047's restricted mode exists: CI checks each contributed file is keywords and literals before anything runs it, and builds it only in restricted mode, in a pull request workflow with no secrets.
  • Conventions like Community Policy's. A folder per policy or initiative, under a category folder, named after its display name; a description required, since it is the entry's text; one definition per pull request; the compiled JSON checked by the build, not committed.
  • Where. Either a folder in this repository, reviewed with the code and under its MIT licence, or a repository of its own, with its own review queue and CI, which the gallery pins like the other sources. The second keeps contributions' pull requests and their checks out of this repository's, and moves independently of a future move to an organisation (ADR-0048).
  • Licence. Contributions under MIT, so the gallery can show them, as Community Policy requires.

Rendering third-party text

  • Every value from a definition is HTML-encoded when the page is written. The index's script sets text with textContent, never innerHTML.
  • The pages set a content security policy that allows only their own scripts and styles.
  • Links in descriptions are shown as text, not followed.

Consequences

  • Good, because anyone can see what Bylaw makes of thousands of real policies, the failures included, with no install.
  • Good, because the coverage page measures the language against Azure's own policies, release by release, as ADR-0042 does for ALZ.
  • Good, because it surfaced 91 ConvertTo-Bylaw bugs before it was built (#70, #71, #72, #73).
  • Good, because Community Policy shows Bylaw against definitions written the way people write their own, not only Microsoft's.
  • Good, because the sources are a list, so contributed Bylaw files can join later as one more source, without redesigning the gallery.
  • Bad, because a release's gallery job takes about half an hour on a GitHub runner, at a guess, as the measurement was on 12 processors. It runs beside the release, not before it.
  • Bad, because the gallery adds several thousand files to gh-pages. Measured on the first full build, 2026-12-01: 3,998 files, 111 MB, of which 31 MB is the highlighting's markup, and 14.5 MB compressed, as Pages serves them and git stores them. The full build took 23 minutes on 12 processors.
  • Bad, because the gallery describes the newest release only. A gallery per version would multiply its size for little use.
  • Neutral, because built-ins named by GUID make unfriendly addresses. The page titles and the index use display names.

Confirmation

  • Unit tests cover the generator on a few definitions of each status:
  • every value is encoded;
  • a failed definition shows its reason and link;
  • an initiative links its members.
  • The pull request check builds the ALZ gallery.
  • After the first release with the gallery, a check of its coverage page against the totals above, at the same pin, confirms the numbers.

Pros and Cons of the Options

  • Good, because it costs one job per release and nothing per pull request.
  • Good, because it is one copy, always the newest release.
  • Bad, because it needs its own small generator and index script.
  • Good, because Zensical's search and navigation would come with it.
  • Bad, because 3,000 more pages per version would slow every documentation build, swell the search index each page loads, and be copied into every version.

The converted built-ins committed to the repository, as the ALZ files are

  • Good, because a change to ConvertTo-Bylaw would show as a diff of real policies in review.
  • Bad, because it would add about 60 MB of third-party JSON and converted files, changing every week. The ALZ copy already gives that review on a set small enough to read.

More Information