r/AZURE • u/positivemark • 10m ago
Media Open-source tool for authoring Azure Policy: write what must be true, compile to policy JSON
There are plenty of ways to deploy Azure Policy (Bicep, Terraform, EPAC), but authoring the definitions is still hand-written JSON: nested allOf/anyOf, long aliases, and logic that describes what's non-compliant rather than what you actually want.
I've built Bylaw, an open-source PowerShell DSL where you describe the compliant state and it compiles that into Azure Policy JSON. An excerpt:
Require 'TLS 1.2 or later' {
Field minimumTlsVersion | Must -Be 'TLS1_2'
}
- Bylaw works out the non-compliance condition for you, including negations and missing properties.
- Short field names expand to full aliases, and misspelt ones fail the build.
- It validates arrays, remediation (DeployIfNotExists/Modify), related resources and initiatives before you deploy.
- No Azure access needed and no deployment: it just produces deterministic JSON you deploy however you already do.
ConvertTo-Bylawconverts existing policies and only succeeds if the round trip produces an identical policy.
I've tested the conversion against all the built-in, Azure Community and ALZ policies. There's a side-by-side gallery and a coverage page listing what it can't handle yet (a few of the source policies turned out to have genuine bugs).
- Docs: https://bylaw.cloud/
- Code: https://github.com/markwragg/PowerShell-Bylaw
- Gallery: https://bylaw.cloud/gallery/
- Coverage: https://bylaw.cloud/gallery/coverage/
Full disclosure: it's built with Claude Code, ADR-driven, with every design decision and PR reviewed by me.
It's pre-release. I'd really value people trying it on their own custom policies and telling me where it breaks.