Insight Tech APAC Blog Logo

Bicep Docs: Generate Module Documentation Straight from the Compiler

stephentulp
December 4, 2026

11 minutes to read

2026 Advent Calendar

Module documentation has a habit of drifting away from the code it describes. Someone renames a parameter, tightens an allowed value, or adds an output, and the README carries on describing a module that no longer exists. Most Platform Teams respond by writing a script to keep the two in step, then maintaining that script forever.

The experimental bicep docs generate command moves that job into the Bicep CLI. It compiles a module and renders documentation from what the compiler already knows: metadata, descriptions, defaults, allowed values, user-defined types, outputs, and referenced modules.

Before bicep docs was announced, two common options were available:

  1. Write a custom script to extract metadata and parameter information from the Bicep file and generate the README automatically.
  2. Use Bicep Docs, which is a command-line tool created by christosgalanor to generate module documentation from Bicep files.

Most of our internal landing-zone assets currently use a custom script to generate module documentation. A platform engineer wrote and has maintained it for some time, and it offers flexibility for customizing the output. A native option is appealing, but I will keep following its development before deciding whether to switch.

I compared the default layouts from Bicep Docs and bicep docs generate to show what each produces.

WARNING!
bicep docs is experimental. Command options, configuration, the template model, and the built-in Markdown layout can change between releases without a breaking-change notice. Pin the Bicep CLI version wherever you generate documentation.

Why Generate Documentation from Code

A hand-written README is a second copy of the module’s interface, and nothing forces the two copies to agree. Review catches the Bicep change. It rarely catches the paragraph three files away that is now wrong.

Generating the document from the compiled module gives each README:

  • A parameter table that matches the real interface
  • Defaults, allowed values, and length limits taken from decorators
  • User-defined types expanded into their nested properties
  • Outputs and the modules the template references
  • Usage examples lifted from files that compile

Generated documentation describes the interface, not the intent. It will not explain why a module exists or when to choose it over another. Keep that guidance in your wiki and let the tool own the reference material.

No Feature Flag Required

Most experimental Bicep capabilities need an entry under experimentalFeaturesEnabled in bicepconfig.json. This one does not. The docs command group is available in Bicep CLI 0.47.16 and later:

Generate Your First README

Start with a preview. --stdout renders the document to the terminal and writes nothing to disk:

bicep docs generate modules/spokeNetworking/spokeNetworking.bicep --stdout

Drop the flag to write the file:

bicep docs generate modules/spokeNetworking/spokeNetworking.bicep

Bicep writes README.md beside the module. The title and summary come from metadata name and metadata description. The built-in layout then adds a navigation list, resource types, parameters, outputs, and cross-referenced modules.

All example Bicep templates and README examples can be found in the Advent Calendar 2026 repo.

Choose Where the Files Go

A README beside each module is the default, and four options change that:

Option Result
--stdout Prints one document to the terminal and writes no file
--outfile <path> Writes one document to exactly that path
--outdir <dir> Writes in that directory; with --pattern, preserves matched folders
--pattern <glob> Documents every module that matches the wildcard

Repositories that follow the Azure Verified Modules layout, with one main.bicep per folder, can document everything in a single command:

bicep docs generate --pattern './modules/**/main.bicep'

If the module names aren’t using main.bicep, you can point the pattern at all module files instead:

bicep docs generate --pattern 'src/modules/**/*.bicep'

Make the Layout Your Own

The built-in layout is a starting point. Bicep renders documentation with Scriban, a lightweight text templating language, and you can supply your own template from bicepconfig.json:

{
  "documentation": {
    "template": {
      "file": "docs/templates/module.scriban"
    }
  }
}

The path is relative to the bicepconfig.json file. Bicep CLI 0.49.2 has no command-line option for choosing a template, so configuration is the only route.

This template writes a short header, a parameters table, and an outputs table:

# {{ module.name }}

{{ module.description }}

Owner: {{ custom.owner }} | Support: {{ custom.supportUrl }}

## Parameters

| Name | Type | Required | Description |
| :--- | :--- | :------- | :---------- |
{{~ for parameter in module.parameters ~}}
| `{{ parameter.name }}` | `{{ parameter.type }}` | {{ if parameter.required }}Yes{{ else }}No{{ end }} | {{ parameter.description }} |
{{~ end ~}}

## Outputs

| Name | Type | Description |
| :--- | :--- | :---------- |
{{~ for output in module.outputs ~}}
| `{{ output.name }}` | `{{ output.type }}` | {{ output.description }} |
{{~ end ~}}

Pass custom values as repeatable command-line arguments. These populate custom.owner and custom.supportUrl in the template:

bicep docs generate modules/spokeNetworking/spokeNetworking.bicep \
  --custom-template-value "owner=Platform Engineering" \
  --custom-template-value "supportUrl=https://example.com/support"

Replace the sample values with your own. Values that are not supplied render as blanks.

The ~ inside the braces trims the whitespace next to a tag, so the loops do not add blank lines that would break the tables.

Let the Linter Guard Your Descriptions

Generated documentation is only as good as the descriptions behind it. Bicep CLI v0.47.16 added linter rules that flag missing descriptions. They are off by default, so turn on the ones you need in bicepconfig.json:

{
  "analyzers": {
    "core": {
      "rules": {
        "use-description-params": { "level": "warning" },
        "use-description-outputs": { "level": "warning" },
        "use-description-types": { "level": "warning" },
        "use-description-type-properties": { "level": "warning" }
      }
    }
  }
}

Keep Documentation Current in CI

Because the documentation comes from the code, a pipeline can prove that it is current: regenerate it, then fail the build if anything changed. The below workflow is available in the repo.

name: Validate Bicep documentation

on:
  pull_request:
    paths:
      - "bicep docs/**/*.bicep"
      - "bicep docs/bicepconfig.json"
      - "bicep docs/**/bicepconfig.json"
      - "bicep docs/**/*.scriban"

  workflow_dispatch: {}

permissions:
  contents: read

jobs:
  docs:
    runs-on: ubuntu-latest
    env:
      BICEP_VERSION: v0.49.2
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7

      - name: Install Bicep
        run: |
          curl -fsSL -o bicep "https://github.com/Azure/bicep/releases/download/${BICEP_VERSION}/bicep-linux-x64"
          chmod +x bicep
          sudo mv bicep /usr/local/bin/bicep
          bicep --version

      - name: Regenerate documentation
        run: |
          find 'bicep docs' -type f -name '*.bicep' \
            -not -path '*/.test/*' -not -path '*/examples/*' -print0 |
            while IFS= read -r -d '' file; do
              relative_file="${file#bicep docs/}"
              output_file="bicep docs/docs/${relative_file%.bicep}.md"
              mkdir -p "$(dirname "$output_file")"
              bicep docs generate "$file" --outfile "$output_file" || exit 1
            done

      - name: Fail when documentation is stale
        run: |
          if [ -n "$(git status --porcelain -- 'bicep docs/docs')" ]; then
            git status --porcelain -- 'bicep docs/docs'
            echo "::error::Module documentation is out of date. Regenerate it and commit the result."
            exit 1
          fi

Understand the Limitations

The command is useful today, and it has edges worth knowing before you depend on it.

  • The feature is experimental. Options, configuration, and the default layout can change without notice.
  • A module must compile before it can be documented. That includes linter rules set to error: an unused parameter under our no-unused-params rule made the command exit with code 1 and left the existing file untouched.
  • Modules that reference a registry are restored before compilation, so CI needs network access, plus credentials for any private registry.
  • Each output path can hold one document. Folders with several entry points need --outfile rather than the default README.md.
  • Example discovery works per folder, so sibling entry points share examples.
  • Bicep uses the bicepconfig.json nearest to each module and does not merge parent files automatically. A nested configuration file loses the repository’s documentation settings unless it declares extends, which Bicep CLI v0.47.16 added for this kind of inheritance.
  • Custom values that are missing render as blanks rather than failing.

Final Thoughts

bicep docs generate turns module documentation from something you remember to update into something you can verify. The command took one line to adopt, and its first run told us more about our own module than the README it would replace: a parameter documented as optional that is not, and three outputs nobody had described.

Start with --stdout against a module you know well and read the result the way a consumer would. Fix the descriptions it exposes, turn on the description linter rules, then add the pull-request check once the output is stable. Keep the CLI version pinned while the feature remains experimental.

References