Part five of the Azure Bicep series covers extracting resources into modules, consuming them through the module block, and shortening long registry references with br and ts aliases in bicepconfig.json.
Key points
- A module is a plain .bicep file with its own params and outputs that compiles and tests on its own.
- The parent template calls it in a module block and reads storageModule.outputs.storageAccountName.
- Module blocks accept the same for loops and if conditions as resource declarations.
- az bicep publish --target br:myregistry.azurecr.io/bicep/modules/storage:v1 pushes the module into an Azure Container Registry.
- References can be a relative file path, br: for ACR or ts: for Template Specs.
- moduleAliases in bicepconfig.json produce short paths like br/CoreModules:storage:v1; one responsibility per module.
Why it matters
If your infrastructure is a pile of loose .bicep files, modules are the step that makes it maintainable: a storage module can be reviewed, versioned and pulled into several repositories instead of copy-pasted.
The catch is the version tag — br/CoreModules:storage:v1 points at a moving target unless you retag deliberately, so decide early whether consumers follow a stable tag or an explicit version per environment. Also confirm each pipeline identity can pull from the registry; a missing AcrPull assignment only surfaces at deploy time. Teams already using template specs gain little beyond the alias syntax, but this is the groundwork before deployments get automated.
Real-world use
- A team with several repositories that keeps shared storage or network modules in one Azure Container Registry.
- An organization distributing approved modules through Template Specs in a dedicated resource group.
- Separate teams working in parallel on the storage, network and App Service blocks of one environment.
- Enforcing naming, security and tagging conventions centrally across projects.
This summary was generated by the agent from the original post on dotnetpro (de). The full text and all rights belong to its author and publisher. Go to original