| name | azure-bicep-patterns |
| description | **UTILITY SKILL** — Reusable Azure Bicep patterns: hub-spoke, private endpoints, diagnostics, AVM composition. WHEN: "hub-spoke Bicep", "private endpoint module", "diagnostic settings", "AVM Bicep composition". USE FOR: Bicep template design, hub-spoke networking, private endpoint patterns, AVM modules. DO NOT USE FOR: Terraform code (use terraform-patterns), architecture decisions (use azure-adr), troubleshooting, diagram generation (use drawio). |
| compatibility | Requires Azure CLI with Bicep extension |
Azure Bicep Patterns Skill
Reusable infrastructure patterns for Azure Bicep templates. Complements
iac-bicep-best-practices.instructions.md (style) and azure-defaults skill (naming, tags, regions).
Canonical sources — the security baseline, AVM-first mandate, naming
conventions, required tags, and unique-suffix rule live in
azure-defaults/SKILL.md and
iac-policy-compliance.md.
This skill restates the rules tersely below for IaC-output convenience
only; in conflict, the canonical sources win.
Quick Reference
| Pattern | When to Use | Reference |
|---|
| Hub-Spoke Networking | Multi-workload environments with shared services | hub-spoke-pattern |
| Private Endpoint Wiring | Any PaaS service requiring private connectivity | private-endpoint-pattern |
| Diagnostic Settings | Every deployed resource (mandatory) | common-patterns |
| Conditional Deployment | Optional resources controlled by parameters | common-patterns |
| Module Composition | Breaking main.bicep into reusable modules | common-patterns |
| Managed Identity Binding | Any service-to-service authentication | common-patterns |
| Budget & Cost Monitoring | Every deployment (mandatory) | budget-pattern |
| What-If / AVM Pitfalls | Pre-deployment validation & AVM gotchas | avm-pitfalls |
| Batch Bicep Formatting | After generating/editing the Bicep tree | npm run format:bicep -- infra/bicep/{project} (wraps bicep format) |
Canonical Example — Module Interface
Every Bicep module in this repo follows the same input/output contract:
- Inputs (required):
name, location, tags, logAnalyticsWorkspaceName
- Outputs (required):
resourceId, resourceName, principalId (use .?principalId ?? '' so modules without managed identity still expose the output)
Full code sample and rationale: references/module-interface.md.
Steps
Applying a pattern in a Bicep template:
- Identify the pattern — match your need to a row in Quick Reference (hub-spoke, private endpoint, diagnostics, conditional, identity, budget)
- Load the reference — read the linked
references/*.md for the chosen pattern; do not load all at once
- Compose the module — follow the Module Interface contract above (
name/location/tags/logAnalyticsWorkspaceName in; resourceId/resourceName/principalId out)
- Pin AVM versions to the latest stable — at plan time, query MCR (
https://mcr.microsoft.com/v2/bicep/avm/res/{path}/tags/list) and pin the highest non-prerelease semver; never reuse a version from training data, a prior project, or references/avm-modules.md. Stale pins require a pin_policy.mode = "exception" block in 04-iac-contract.json (see azure-defaults skill). Enforced by npm run validate:avm-versions:freeze.
- Add diagnostics + budget — every deployed resource gets a diagnostic setting; every deployment gets a budget with 80%/100%/120% forecast alerts
- What-if before deploy — run
az deployment group what-if and review for unexpected deletes, SKU downgrades, or auth changes
- Validate —
bicep build + bicep lint + npm run validate:iac-security-baseline
Rules
- Hub-Spoke: Hub holds shared infra; spokes peer to hub only; NSGs per subnet
- Private Endpoints: Always wire PE + DNS Zone Group + DNS Zone; see group ID table in reference
- Diagnostics:
categoryGroup: 'allLogs' + AllMetrics; pass workspace name not ID
- Conditional:
bool params with defaults; guard outputs with ternary
- Identity:
guid() for idempotent role names; principalType: 'ServicePrincipal'; scope narrowly
- Budget: 3 forecast thresholds (80%/100%/120%); amount and emails MUST be parameters
- What-If: Run before every deploy; watch for unexpected deletes and SKU downgrades
- AVM: ALWAYS pin to the latest published stable version (resolve at plan time via MCR
tags/list); wrap modules to override defaults; verify outputs in README. Stale pins require a pin_policy exception block — see azure-defaults skill.
- AVM Version Source of Truth: MCR tag listing (
mcr.microsoft.com/v2/bicep/{module}/tags/list) is authoritative.
Helpers and doc tables are NOT — they go stale. Validator: npm run validate:avm-versions.
Gotchas
Reference Index
Learn More
| Topic | How to Find |
|---|
| AVM module catalog | mcp_azure-mcp_documentation — command: "microsoft_docs_search", query: "Azure Verified Modules registry Bicep" |
| Resource type schema | mcp_azure-mcp_documentation — command: "microsoft_docs_search", query: "{resource-type} Bicep template reference" |