Forum Discussion
Why does PSRule produce more findings than Template Analyzer when both use PSRule Azure rules?
PSRule for Azure vs Template Analyzer: Why Are the Findings Different When Scanning the Same Bicep Infrastructure?
Hi everyone,
I'm investigating differences between PSRule for Azure and Template Analyzer when scanning the same Bicep-based Infrastructure-as-Code repository in Azure DevOps.
My understanding is that Template Analyzer integrates with PSRule for Azure. Therefore, I expected both tools to produce broadly consistent findings. However, I'm observing differences in both the number and types of findings.
Environment:
- Azure DevOps Pipelines
- Bicep and Bicep parameter files (.bicepparam)
- Azure Verified Modules (AVM)
- Template Analyzer 0.8.6
- PSRule.Rules.Azure version 1.32.1 or later
Observed results:
PSRule for Azure: 18 findings.
Examples:
- Microsoft.DBforMySQL/flexibleServers/mysql-dev: Consider using Microsoft Entra ID-only authentication.
- Microsoft.Storage/storageAccounts/vulnstorageavm001: Storage accounts should only accept secure traffic.
Template Analyzer: 10 findings.
Examples:
- AZR-000216: Azure.Template.Resources
- AZR-000166: Azure.Resource.UseTags
- AZR-000168: Azure.ResourceGroup.Name
- AZR-000268: Azure.VNET.Name
The PSRule results appear to include security configuration checks against individual Azure resource types, whereas Template Analyzer reports a different set of template validation, naming, tagging, and governance-related findings.
Questions:
- Does Template Analyzer expand Bicep modules and Azure Verified Modules in the same way as standalone PSRule for Azure?
- Does Template Analyzer bundle a specific version of PSRule.Rules.Azure, or does it use the version installed in the pipeline? How can we identify the effective version?
- Is Template Analyzer intentionally limited to a subset of PSRule findings, even when IncludeNonSecurityRules is set to true?
- Are additional configuration settings required to enable Bicep parameter-file expansion and nested module expansion?
- Does Template Analyzer support the same Bicep parameter-file scenarios as standalone PSRule, particularly when using AVM modules from a registry?
- For repositories primarily using Bicep and AVM, should standalone PSRule for Azure be considered the more comprehensive option for Azure resource security assessment?
My objective is to understand whether these differences are expected and identify the recommended scanning configuration for Bicep deployments using AVM modules and parameter files in Azure DevOps.
Any technical clarification or recommended configuration examples would be greatly appreciated.
Thanks in advance!
2 Replies
- AmezingtechsataraIron Contributor
Short version: yes, the difference is expected. The two tools look like they're running the same rules because the rule IDs match, but they aren't running the same engine.
Template Analyzer doesn't run the PSRule engine. Its rules are a set of JSON rules shipped in its built-in rules file, and they use the same rule names as PSRule's rules, which is why you see AZR-000166 and the rest in both outputs. There is no PSRule.Rules.Azure version bundled inside Template Analyzer to keep in step with 1.32.1, so your second question doesn't quite apply the way you'd expect.
That also answers the count difference. Template Analyzer's built-in rule set is a subset of what PSRule ships, focused on template structure, so the resource-level security checks like the MySQL Entra-only authentication and the storage secure-transfer findings only appear on the PSRule side. The include-non-security-rules switch only turns on the non-security rules inside Template Analyzer's own set; it doesn't pull in the rest of PSRule's rules.
The other thing to check is parameters. Template Analyzer evaluates the ARM JSON your Bicep compiles to, and if you don't pass a parameters file with the -p option it invents placeholder values, which its own documentation says makes results less accurate. A lot of the security checks depend on parameter values, so they can be skipped or judged against a made-up value. Standalone PSRule expands Bicep itself, modules included, and reads parameter files, so it sees the real values. On an AVM-heavy repo that difference alone can account for several findings.
So for your last question: yes, for a Bicep and AVM repo I'd treat standalone PSRule for Azure as the scanner of record, and Template Analyzer as the lighter pre-deployment gate. If you want to narrow the gap before settling on that, pass Template Analyzer the real parameter values with -p and run it with --include-non-security-rules, then compare again on the same compiled template. The two will never match exactly though, because they're different engines with different rule sets.
- maskwillIron Contributor
The difference is likely expected. Template Analyzer and standalone PSRule for Azure should not be assumed to produce identical findings, even when they use related Azure rules.
The main things to check are:
1. Rule coverage: Template Analyzer may expose only a subset of PSRule checks. `IncludeNonSecurityRules` does not necessarily enable every standalone PSRule rule.
2. Versioning: Check the effective PSRule.Rules.Azure version used by each scanner; don't assume Template Analyzer uses the version installed separately in your pipeline.
3. Bicep expansion: Verify that nested modules and registry-based AVM modules are fully expanded before scanning.
4. Parameter files: Confirm that `.bicepparam` values are actually passed into the analysis. Different parameter handling can change findings.
For Template Analyzer 0.8.6, its NuGet dependency specifies PSRule.Rules.Azure 1.33.2 or later, so it is not necessarily using your separately installed 1.32.1 version.
Azure.Templates.Analyzer.Core 0.8.6
Recommendation: For Bicep + AVM repositories, use standalone PSRule for Azure as your primary assessment tool. It provides more explicit control over expansion and parameter handling.
Useful configuration:
yaml
```yaml
configuration:
AZURE_BICEP_FILE_EXPANSION: true
```
For `.bicepparam` support, note that PSRule added this in version 1.34.0.
PSRule for Azure
Documentation: [PSRule Bicep configuration https://azure.github.io/PSRule.Rules.Azure/using-bicep/.