March 18, 2025

ACR Bicep templates

Photo Credit: Dall-E by OpenAI

🚀 Deploying Bicep Templates from Azure Container Registry (ACR)

Bicep is an Infrastructure-as-Code (IaC) language that simplifies Azure resource deployments.
By storing Bicep templates in Azure Container Registry (ACR) as OCI artifacts, teams can benefit from: ✅ Version control
Secure centralized storage
Simplified deployment workflows

1️⃣ Publishing Bicep Templates to ACR

First, store your Bicep template in ACR so it can be retrieved and deployed anywhere.

Alt text
Alt text

Login to Azure

az login

# Set variables
$ACR_NAME=myacr.azurecr.io  # Change this to your ACR
$BICEP_FILE=main.bicep               # Your Bicep file
$TAG=latest                          # Change as needed (e.g., 'v1', 'dev', 'prod')

Publish Bicep to ACR

az bicep publish --file $BICEP_FILE --target br:$ACR_NAME/bicep/modules/core/storage/storageaccount:$TAG

Once pushed, your Bicep template is available in ACR for deployments.

2️⃣ Deploying Bicep Templates from ACR

Use az deployment group create to deploy directly from ACR.

Copy code
az deployment group create \
  --resource-group my-rg \
  --template-uri br:$ACR_NAME/bicep/modules/core/storage/storageaccount:$TAG \
  --parameters environmentSuffix="-prd"

💡 Customize parameters like environmentSuffix to deploy across different environments.

3️⃣ Pulling Bicep Templates for Editing

Bicep templates cannot be pulled directly from ACR, so you need ORAS.

  • Install ORAS for Windows Manual Installation (Recommended)

    Go to the latest ORAS releases: 🔗 https://github.com/oras-project/oras/releases/latest

    Move the Executable to a System Path suck as: C:\Windows\System32

  • Retrieve a Bicep Template Using ORAS


oras login divaacrweudev.azurecr.io -u 00000000-0000-0000-0000-000000000000 -p "<your-access-token>"
oras pull divaacrweudev.azurecr.io/bicep/modules/core/storage/storageaccount:latest

📌 To get an access token, use:


az acr login --name divaacrweudev --expose-token

4️⃣ Preview & Edit Bicep Templates in VS Code

Once pulled, open the Bicep file in VS Code:

Try the Bicep Visualizer

Open the Bicep file

Press Ctrl + Shift + P → Search for Bicep: Open Visualizer

See a graphical view of your deployment!

Peace... 🍀

Tech Innovation Hub
Modern Software Architecture

Exploring cutting-edge technologies and architectural patterns that drive innovation in software development.

Projects

© 2025 Tech Innovation Hub. Built with Gatsby and modern web technologies.