Authoring Azure Policies has always been somewhat difficult, since there has not been an easy way to validate if the JSON is written correctly or not. You never really knew until you tried to deploy, only to find out that you had a typo or a missing parameter. It would have been nice to be able to validate the correctness and best practices as early in development workflow as possible.
Well, now it’s possible, thanks to Microsoft open-sourcing the Azure Policy Linter. However, since it’s a .NET tool that I have no desire to install on my machine, and because I appreciate portability, I packaged it as a Docker container. It’s easy to run locally during development or in CI, and just as easily, it can be used by AI agents to validate authored policies in a deterministic way.
The repository janik6n/az-policy-linter: Containerized version of Azure Policy Linter includes instructions on how to build the container, some example policies, and instructions on how to run it. I’ve also made it possible to return a non-zero exit code using --fail-on-findings if any findings are reported.
I decided to open-source this as well. Maybe you’ll find it useful! And thanks to Microsoft for making this tool available!