Create Azure Container Registry With Bicep

In this blog post we will show how to create an Azure Container Registry (ACR) using Bicep declarative.

about Bicep

The Bicep language was created specifically for deploying Azure resources, and it offers a number of benefits over other methods of deploying to Azure. First, the syntax is extremely easy to learn and use, making it perfect for developers who are new to Azure. Additionally, Bicep files can be used throughout the development process, from development through production, ensuring that your resources are always in sync.

Note the Bicep is being developed by Microsoft and it is s a domain-specific language (DSL) that only works on Microsoft Azure. You can look at Bicap as Terrafrom by for Microsoft Azure only.

Creating Azure Container Registry with Bicep

To be successful and create an ACR with Bicep, you will need VS Code and an Azure Subscription.

I will start with creating a file called acr.bicep in VS Code, once creating the file VS Code will ask to install the Bicep extension, go ahead and install it.

After installing the Bicep extension, I will start typing in file container and Bicep bring up the option to create a container registry. click on the res-container-registry option.

After clicking on res-container-registry option Bicep will have 90% of the code ready to go.

Change the name and location option to the ACR name and set the location to the Resource Group location by using resourceGroup().location in the location.

resource containerRegistry 'Microsoft.ContainerRegistry/registries@2021-06-01-preview' = {
  name: 'ntweeklyacr'
  location: resourceGroup().location
  sku: {
    name: 'Basic'
  properties: {
    adminUserEnabled: true

To visualize the deployment, click on the Visualizer icon and it will display the ACR that is about to be deployed to Azure.

Below you can see the visualization.

Now that we have to code ready, we need to use Azure PowerShell to connect, install the Bicep PowerShell module, create a resource group and deploy the Bicep file.

Note: In code below will install Bicep on a Linux machine. If you are on a Windows machine, use Winget (winget install -e –id Microsoft.Bicep) to install Bicep and skip the curl, chmod and sudo mv commands.

# Connect
Connect-AzAccount -DeviceCode
Set-AzContext -Subscription pay-as-you-go # optional if you have more than one subscription

# Install Bicep PowerShell
Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force

curl -Lo bicep
chmod +x ./bicep
sudo mv ./bicep /usr/local/bin/bicep
bicep --help

# Create RG using PowerShell 
New-AzResourceGroup -Name vnetlab -Location westus  # Optional if you need a new RG

# Deploy 
New-AzResourceGroupDeployment -ResourceGroupName vnetlab -TemplateFile ./acr.bicep 

After deploying the code I should see the ACR in the Azure portal as shown below.

2 thoughts on “Create Azure Container Registry With Bicep”

Comments are closed.