AI-powered Azure Bicep What-If deployment advisor with automated safety reviews
Project description
bicep-whatif-advisor
AI-powered deployment safety gate for Azure Bicep and ARM templates. Pipe Azure What-If output through an LLM (Anthropic Claude, Azure OpenAI, or Ollama) to detect infrastructure drift, validate PR intent alignment, and evaluate custom risk dimensions. Integrates into GitHub Actions and Azure DevOps with zero-config platform detection, automatic PR comments, and configurable risk thresholds. Also works as a standalone CLI for local What-If analysis.
How It Works
Pipe Azure What-If output to the tool in your CI/CD pipeline. It auto-detects the platform, collects PR metadata and code diff, then sends everything to the LLM for analysis across two built-in risk categories:
- Infrastructure Drift - Detects changes not in your code (out-of-band modifications)
- PR Intent Alignment - Ensures changes match PR description
You can also add custom risk assessment agents via markdown files to evaluate additional dimensions like compliance, cost, risky operations, or naming conventions. See Custom Agents below.
Known Azure What-If noise (etag, provisioningState, etc.) is filtered before LLM analysis. Results are posted as a PR comment and the pipeline exits with code 0 (safe) or 1 (unsafe) based on configurable thresholds.
Example PR Comment:
production What-If Summary (non-blocking)
Risk Assessment Risk Level Key Concerns Infrastructure Drift High Existing Paris Key Vault being modified when not present in code diff PR Intent Alignment High PR intends to add Berlin branch but What-If shows Paris branch changes Summary: The What-If output shows modifications to existing Paris branch resources rather than creating new Berlin branch resources. Most changes appear to be template refactoring (hardcoded to dynamic references) and What-If noise (retention policies, metadata). The only significant change is disabling public network access on an existing Key Vault.
📁 View changed resources (1 High Confidence)
...⚠️ Potential Azure What-If Noise (10 Low Confidence)
...📂 Raw What-If Output
...Verdict: ❌ UNSAFE
Reasoning: This deployment is unsafe due to a complete mismatch between PR intent (adding Berlin branch) and What-If output (modifying existing Paris Key Vault). The changes indicate both infrastructure drift and unintended modifications to existing resources not mentioned in the PR description.
Generated by bicep-whatif-advisor
Quick Start
GitHub Actions:
- name: Deployment Safety Gate
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pip install bicep-whatif-advisor[anthropic]
az deployment group what-if \
--resource-group ${{ vars.AZURE_RESOURCE_GROUP }} \
--template-file main.bicep \
--exclude-change-types NoChange Ignore \
| bicep-whatif-advisor
Azure DevOps:
- script: |
pip install bicep-whatif-advisor[anthropic]
az deployment group what-if \
--resource-group $(RESOURCE_GROUP) \
--template-file main.bicep \
--exclude-change-types NoChange Ignore \
| bicep-whatif-advisor
env:
ANTHROPIC_API_KEY: $(ANTHROPIC_API_KEY)
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
Configuration
Risk Thresholds
Each risk bucket has an independent threshold: low, medium, high (default: high — most permissive).
# Block on medium or high risk
bicep-whatif-advisor \
--drift-threshold medium \
--intent-threshold medium
Skip individual buckets with --skip-drift or --skip-intent.
Custom Agents
Add custom risk assessment dimensions using markdown files with YAML frontmatter. Each file defines a new risk bucket that runs alongside the built-in ones:
---
id: compliance
display_name: Compliance Review
default_threshold: high
---
**Compliance Risk:**
Evaluate whether changes comply with organizational policies.
Risk levels for compliance:
- high: Encryption disabled, public access enabled, data residency violations
- medium: Policy assignment changes, unapproved resource types
- low: Tag updates for compliance metadata, monitoring additions
Point the tool at a directory of agent files:
bicep-whatif-advisor --ci \
--agents-dir ./agents/ \
--agent-threshold compliance=medium
Custom agents support --agent-threshold for per-agent thresholds and --skip-agent to disable individual agents. See the User Guide for details.
LLM Providers
Defaults to Anthropic Claude. Also supports Azure OpenAI and Ollama:
# Azure OpenAI
pip install bicep-whatif-advisor[azure]
bicep-whatif-advisor --provider azure-openai
# Local Ollama
pip install bicep-whatif-advisor[ollama]
bicep-whatif-advisor --provider ollama --model llama3.1
Config File
Define settings in a YAML file instead of passing many CLI flags. CLI flags always override config values:
# whatif-config.yaml
provider: azure-openai
ci: true
drift_threshold: medium
agents_dir: ./agents
bicep-whatif-advisor --config-file whatif-config.yaml
Additional Options
# Output formats: table (default), json, markdown
bicep-whatif-advisor --format json
# Include raw What-If output in PR comment
bicep-whatif-advisor --include-whatif
# Label comments for multi-environment pipelines
bicep-whatif-advisor --comment-title "Production"
# Non-blocking mode (report without failing pipeline)
bicep-whatif-advisor --no-block
See the User Guide for all CLI flags and the CI/CD Integration Guide for complete pipeline setup.
Documentation
- Quick Start - Get running in 5 minutes
- User Guide - Complete feature reference and CLI flags
- CI/CD Integration - Pipeline setup for GitHub Actions, Azure DevOps, etc.
- Risk Assessment - Deep dive into AI risk evaluation
- Technical Specifications - Architecture, design, and module specs
Support
- Issues: Report bugs or request features via repository issues
- Contributing: Pull requests welcome!
- License: MIT - see LICENSE for details
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bicep_whatif_advisor-3.7.2.tar.gz.
File metadata
- Download URL: bicep_whatif_advisor-3.7.2.tar.gz
- Upload date:
- Size: 73.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5fc19c0588a40323404713380af670b477e45ced2189a0d6f2c3ebd3e32ee90
|
|
| MD5 |
fd9b8ae577992d35ae058bff7198c64e
|
|
| BLAKE2b-256 |
25728dbdfb64c74d82111bbf3710dee276bca7a2ba79a52bc99925b3015fcb0a
|
Provenance
The following attestation bundles were made for bicep_whatif_advisor-3.7.2.tar.gz:
Publisher:
publish-pypi.yml on neilpeterson/bicep-whatif-advisor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bicep_whatif_advisor-3.7.2.tar.gz -
Subject digest:
e5fc19c0588a40323404713380af670b477e45ced2189a0d6f2c3ebd3e32ee90 - Sigstore transparency entry: 1013397040
- Sigstore integration time:
-
Permalink:
neilpeterson/bicep-whatif-advisor@1fb044bb361ba2237a20a2f95a0d5b56c27423ed -
Branch / Tag:
refs/tags/v3.7.2 - Owner: https://github.com/neilpeterson
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@1fb044bb361ba2237a20a2f95a0d5b56c27423ed -
Trigger Event:
release
-
Statement type:
File details
Details for the file bicep_whatif_advisor-3.7.2-py3-none-any.whl.
File metadata
- Download URL: bicep_whatif_advisor-3.7.2-py3-none-any.whl
- Upload date:
- Size: 51.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f3ec34fc3f9a9cc79148d6e11ffe7f9ef0ecf93f9460146334b92381da4e0e2
|
|
| MD5 |
cb0364d15aaad1ba2564025ade1a0ec6
|
|
| BLAKE2b-256 |
e153363f89cb3265017f04fb1929aaa470508d02f982621291a1fcb94427430a
|
Provenance
The following attestation bundles were made for bicep_whatif_advisor-3.7.2-py3-none-any.whl:
Publisher:
publish-pypi.yml on neilpeterson/bicep-whatif-advisor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bicep_whatif_advisor-3.7.2-py3-none-any.whl -
Subject digest:
7f3ec34fc3f9a9cc79148d6e11ffe7f9ef0ecf93f9460146334b92381da4e0e2 - Sigstore transparency entry: 1013397094
- Sigstore integration time:
-
Permalink:
neilpeterson/bicep-whatif-advisor@1fb044bb361ba2237a20a2f95a0d5b56c27423ed -
Branch / Tag:
refs/tags/v3.7.2 - Owner: https://github.com/neilpeterson
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@1fb044bb361ba2237a20a2f95a0d5b56c27423ed -
Trigger Event:
release
-
Statement type: