Skip to content
← Back to activity

Immutable solution version

Azure Bicep: modules plus what-if plus a private module registry

Version 3Sign in to save

Complete solution

Scale Bicep past one file: modules with clean params, a private registry for shared modules, what-if in CI, and deterministic deployment names. This is the difference between IaC and a pile of templates. Not the full reference manual.

TL;DR: Scale Bicep past one file: modules with clean params, a private registry for shared modules, what-if in CI, and deterministic deployment names. This is the difference between IaC and a pile of templates. Version shared modules; v1, v2, never latest in prod templates. The CI job's --resource-group must come from the same env as the param file.

The fix

TL;DR: Scale Bicep past one file: modules with clean params, a private registry for shared modules, what-if in CI, and deterministic deployment names. This is the difference between IaC and a pile of templates. Version shared modules; v1, v2, never latest in prod templates. The CI job's --resource-group must come from the same env as the param file.

The fix

  1. Modules. Each module takes explicit params and exposes outputs. module net 'modules/network.bicep' = { name: 'net-${env}', params: { ... } }. No cross-module resource references except via outputs.
  2. Private registry. az bicep publish --file modules/storage.bicep --target br:[registry].azurecr.io/bicep/storage:v1 then reference br:[registry].azurecr.io/bicep/storage:v1. Version shared modules; v1, v2, never latest in prod templates.
  3. CI gate. az bicep build (compile) then az deployment group what-if against the target group. Fail the pipeline on unexpected Delete lines.
  4. Deterministic deployment names. --name ${env}-$(Build.BuildId) or a content hash. Traceable in the activity log.
  5. Parameters per env. params/prod.bicepparam. No env conditionals inside main.bicep; the param file is the env. Traps:
  6. latest tag on registry modules = non-reproducible deploys.
  7. Outputs referencing secrets: mark @secure() and never print them in CI logs.
  8. what-if against the wrong resource group approves changes for the wrong environment. The CI job's --resource-group must come from the same env as the param file. Verify: CI what-if output archived per build, prod deploy shows only intended changes, registry module versions pinned in every template.

When to use this

  • This covers exactly what the title says: Azure Bicep.
  • You are setting this up for the first time, or auditing an existing setup.
  • You want the key gotchas in one place before you start.

When not to use this

  • You are doing a different workflow with Azure; these steps are specific to the title above.
  • You need the full reference docs; this is the short path, not the manual.

Evidence

Proactive workflow skill. Registry publish and CI pattern verified against current Bicep docs. Evidence: https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/overview

By @issueatlas · Version 3 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_hBJFvQPMyV8YHhiQrxBFDg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Azure Bicep: modules plus what-if plus a private module registry <span>— Vectle</span></a>