Loading...

How to use Azure Container registry to standardize deployments using Bicep across your organization

How to use Azure Container registry to standardize deployments using Bicep across your organization

This post is part of a series

I like to deploy my Azure resources using Bicep - If you never heard about it, I blogged a while ago on how to get started with Bicep - please catch up first!

You might now know, that I am a big fan of infrastructure as code

  • no more manual clickety-clackety in the Azure portal
  • it’s just less prone to human error
  • our deployment files can be logged into source control

I did not realize that many fellow developers still copy/paste code from their previous Bicep files to their current files. Or, even worse, they need to ask other developers in the organization how they use to deploy a certain resource. Infrastructure as Code is good, but wouldn’t it be better if we had a centralized repository across our organization with ready-to-use deployment files?

Azure Container Registry to the rescue!

What is Azure Container Registry?

Azure Container Registry (ACR) is a powerful tool for managing Docker container images, and it comes with several practical benefits:

  • ACR works effortlessly with other Azure services like Azure DevOps (more in this in a later part of this series). This makes it easier to set up continuous integration and deployment (CI/CD) pipelines
  • ACR provides a private, secure registry for your container images - You can control access with Microsoft Entra Id
  • It supports both Linux and Windows containers

Using ACR for our Bicep files will help with managing, versioning, and deploying our IaC as efficiently as possible. (And who wouldn’t want to spend less time on deployments 🤭)

How to create an Azure Container Registry

⚠️ If you don’t already have Docker installed, please go ahead and do this! If you are unsure, you can verify the installation in your terminal with

docker --version, ot should return something like this: Docker version 27.1.1, build 6312585 - if your version number is significantly lower, an update can’t hurt!

Once this is done, in your terminal using Azure CLI

# Set variables
$ACR_NAME="building-blocks"
$RESOURCE_GROUP="building-blocks-rg"
$LOCATION="westeurope"
# Create the ACR
az acr create --name $ACR_NAME --resource-group $RESOURCE_GROUP --location $LOCATION --sku Basic

(You can choose a name and a location to your liking!)

Build and publish your Bicep modules to the ACR

We will use the bicep files that we created in the last blog post of this series - if you did not follow that one, please do so now:How to deploy Azure LogAnalytics Workspace and link Application Insights to it and publish them to the ACR.

In your terminal using Azure CLI:

# Log in to the ACR
az acr login --name $ACR_NAME
# Publish the Log Analytics workspace module
bicep publish --file ./loganalyticsworkspace.bicep --target br:$ACR_NAME.azurecr.io/bicep/modules/loganalyticsworkspace:1.0.0
# Publish the Application Insights module
bicep publish --file ./appinsights.bicep --target br:$ACR_NAME.azurecr.io/bicep/modules/appinsights:1.0.0

If you gave your modules names in camelCase, you will get an error - only lower case letters are allows –> ask me how I know 🙄

Update your main Bicep File

As a last step, we will update our main Bicep file:

param location string = resourceGroup().location
param logAnalyticsWorkspaceName string
param appInsightsName string
param applicationType string = 'web'
// Link the Log Analytics workspace module from ACR
module logAnalytics 'br:<yourACRName>.azurecr.io/bicep/modules/loganalyticsworkspace:1.0.0' = {
name: 'logAnalyticsDeployment'
params: {
location: location
logAnalyticsWorkspaceName: logAnalyticsWorkspaceName
}
}
// Link the Application Insights module from ACR
module appInsights 'br:<yourACRName>.azurecr.io/bicep/modules/appinsights:1.0.0' = {
name: 'appInsightsDeployment'
params: {
location: location
appInsightsName: appInsightsName
applicationType: applicationType
logAnalyticsWorkspaceId: logAnalytics.outputs.logAnalyticsWorkspaceId
}
}

Verify that the modules got published

Now we want to see that things worked, right? Easy enough, you can run az acr repository list --name $ACR_NAME --output table, which will return

bicep modules in registry

Conclusion

With ACR, you can now setup templates on how you want to deploy resources across the organization. This is especially helpful if you have resources with lots of properties like VMs :-). In the next blog post, I will cover how to utilize this approach in in Azure DevOps- Stay tuned!

Published on:

Learn more
Luise Freese: Consultant & MVP
Luise Freese: Consultant & MVP

Recent content on Luise Freese: Consultant & MVP

Share post:

Related posts

You are holding GitHub Copilot Wrong!

Most developers think that one can’t really use GitHub Copilot wrong. There is a chat interface that lets you also choose a model, so th...

8 months ago

You are holding GitHub Copilot Wrong!

Part 0 showed why constant prompting, re-prompting, and steering GitHub Copilot feels fragile. Not because Copilot is unreliable, but because ...

8 months ago

Building a Multi-Hierarchy Ticket Classification System (Because Keywords Aren't Enough)

Look, I love a good keyword-based system as much as the next developer. They’re fast, predictable, and when your user says “VPN,&r...

8 months ago

Secretless cross-tenant dataverse access

Client secrets are like hiding your house key under the mat; easy to grab and impossible to audit. Certificates are just slightly better, beca...

10 months ago

How Azure CLI handles your tokens and what you might be ignoring

Running az login feels like magic. A browser pops up, you pick an account, and from then on, everything just works. No more passwords, no more...

10 months ago

How Dev Proxy teaches you to make your apps more resilient

I added Microsoft Dev Proxy to my Mermaid → Dataverse converter, because I wanted to test how it handled rate limits and API errors. What I go...

10 months ago

Building Azure functions that never store secrets — ever

What if your function could hit Microsoft Graph with no client secrets, no certs, and no Key Vault entries? That is exactly what a Managed id...

10 months ago

Introducing Mermaid to Dataverse Converter

Why diagrams matter (and why they usually fail us) Entity-Relationship Diagrams (ERDs) are the universal shorthand for talking about data mode...

11 months ago

It’s OK to be seen trying

It’s OK to be seen trying Somewhere along the way, we started believing that you’re only allowed to speak after you’ve figured everything out....

1 year ago

Stuck in pilot - Part 1: no foundations, no future

“We just need to test the AI. We’ll figure out the data later.” That sentence has quietly killed more AI pilots than any model failure ever ...

1 year ago

Newsletter

Get the latest Dynamics 365 and Power Platform content in your inbox

A curated digest of community blogs, product news, videos, and podcasts — delivered without the noise.

Weekly updates Unsubscribe anytime Fresh community picks
We use your email only for the newsletter and you can unsubscribe at any time.
By subscribing, you agree to the privacy policy.