Publishing Bicep Modules with OCI
Stephen Tulp
December 2, 2026
8 minutes to read
Container registries are no longer limited to container images. They also
distribute Helm charts, signatures, software bills of materials, and other
Open Container Initiative (OCI) artifacts. Bicep’s experimental ociEnabled
feature brings reusable modules into that model.
Platform teams that already use GitHub Container Registry (GHCR) can publish versioned Bicep artifacts beside the rest of their internal software packages. In this post, we will walk through the module workflow for publishing Bicep modules to GHCR.
WARNING!
OCI support in Bicep is experimental and may change in future releases. Use it with caution.
Why Use an OCI Registry?
Bicep has supported private module registries backed by Azure Container Registry for a while. We have used it to publish custom modules for developers and consumers, but adoption outside mature platform teams has been limited.
Some barriers to adoption include:
- Azure Container Registry has a small cost.
- Access controls and configuration are tied to Azure.
- Teams may prefer to host modules alongside their existing GitHub packages.
Adding an OCI-compatible registry such as GHCR can make sense when your Bicep modules already live beside GitHub source code, issues, workflows, and release automation.
An OCI registry gives each module:
- A stable repository name
- Version tags, which remain unchanged only when the registry or release process prevents overwriting published versions
- Access controls
- A familiar pull and publish workflow
- A package that can be promoted and audited with the rest of the software delivery process
GHCR does not replace the repository holding the Bicep source modules. It provides a versioned distribution mechanism for compiled modules that consumers can use independently of the source repository.
Enable OCI Registry Support
Add ociEnabled to the bicepconfig.json that applies to the Bicep files:
{
"experimentalFeaturesEnabled": {
"ociEnabled": true
}
}
The Bicep CLI warns when experimental features are enabled. That warning is expected.
How OCI Registry Support Changes Authentication
By default, Bicep uses the Azure Container Registry SDK for registry
operations. Enabling ociEnabled switches all OCI registry traffic, including
ACR and Microsoft Container Registry, to ORAS transport.
The authentication path does not change for every registry:
- ACR uses Azure credentials, including managed identities.
- MCR supports anonymous access for public artifacts.
- GHCR and self-hosted OCI registries use Docker-compatible credentials.
With the feature active, registry failures do not fall back to the ACR SDK. Validate the complete publish, restore, build, and deployment path before adopting the feature.
Authenticate with GHCR
Create a GitHub personal access token (classic) with the package permissions
required for the operation. Publishing requires write:packages; pulling a
private package requires read:packages.
Keep the token in an environment variable or secret store. Do not place it directly in documentation, scripts, or source control.
export CR_PAT='value-from-your-secret-store'
echo "$CR_PAT" | docker login ghcr.io \
--username USERNAME \
--password-stdin
The Docker credentials saved by this login are available to Bicep for subsequent registry operations.
For GitHub Actions, prefer the automatically issued GITHUB_TOKEN and grant
the package permission explicitly. It can publish packages associated with the
workflow repository:
permissions:
contents: read
packages: write
If the package already exists but was published outside that repository’s
workflow, connect the package to the repository or grant the workflow
repository access before using GITHUB_TOKEN.
Publish a Module
The IaC, workflows and code for this are in the Advent Calendar - 2026 repo.
A Bicep registry reference uses this structure:
br:<registry-host>/<repository>:<tag>
From the oci/ directory, publish the spoke networking module to a repository
named modules/spoke-networking:
bicep publish \
src/modules/spokeNetworking/spokeNetworking.bicep \
--target br:ghcr.io/tulpy/modules/spoke-networking:v1.2.3
The target has four parts:
br:selects the Bicep registry schemeghcr.iois the OCI registry hosttulpy/modules/spoke-networkingis the package repositoryv1.2.3is the published version
Use a full semantic version such as v1.2.3 for each release, and do not
republish an existing version. OCI tags can be moved unless the registry or
release process prevents overwriting them, so a version tag identifies the
same artifact only while it remains unchanged. Avoid using a moving latest
tag for reproducible deployments.
Consume the Module
Reference the registry module in another Bicep file in the same way as a module published to Azure Container Registry. This example consumes a spoke network as part of the Platform Identity orchestration module.

Supply the parameters required by the module just as you would for a local module reference. When a version tag is never overwritten, every consumer restoring that version receives the same published module artifact.
Inspect the Package in GHCR
GHCR stores an OCI artifact rather than a directory of ordinary files. Use the GitHub Packages page for a package-oriented view:

You can also see previous versions of the package on the GitHub Packages page.

You can also install ORAS to inspect the OCI manifest and tags from the command line:
List the published versions:
oras repo tags ghcr.io/tulpy/modules/spoke-networking
Inspect the selected manifest:
oras manifest fetch \
ghcr.io/tulpy/modules/spoke-networking:v1.2.3 \
--pretty

The manifest describes the OCI layers associated with the Bicep artifact. It is the registry equivalent of package metadata, not a conventional source-code tree.
Publish from GitHub Actions
The example workflow runs for pull requests and pushes to main. It builds and
lints selected modules for both events, but skips publishing on pull requests.
After a merge, the push-to-main run publishes only after those checks pass.
The workflow can also be started manually.
The example workflow
selects modules by changed paths. When run manually, it accepts a version such
as v1.2.3; otherwise, it defaults to a generated v1.<run-number> tag.
That generated tag is not a full semantic version. Use a full semantic version
for releases and do not republish an existing version.
- Select modules based on changed paths or repository patterns.
- Run lint and build commands for each selected module.
- Publish the modules only after validation succeeds on a push to
mainor a manual run.
Final Thoughts
The ociEnabled feature makes Bicep feel less like a collection of repository
files and more like a module ecosystem. GHCR can become a natural distribution
point when modules and their automation already live in GitHub, while consumers
continue to use the familiar br: registry syntax.
The capability is still experimental, so keep the feature gate and Bicep version visible in your platform engineering standards. Start with a small non-critical module, test the complete release and restore path in CI, and measure the operational fit before adopting it broadly.