Bicep offers the ability to store your modules in a registry in Azure. This is based on storing them in an Azure Container Registry (ACR).
This approach offers several advantages, especially regarding DevOps practices, version control, shared access, and reusability.
Let’s consider the module below, which creates several Azure Virtual Desktop (AVD)- related resources, such as host pools, workspaces, and application groups.
Publishing your modules to an ACR is quite easy. In this example, I’ll use Azure CLI. First, create an ACR in case you don’t have one yet. Since an ACR is just another resource in Azure, you can use Bicep to create one, as shown below.
Now use the publish command, provide the bicep module you want to publish, and provide the target location, the ACR, and where you want to store it.
The result looks like the below: a container repository is visible under repositories.
You can now start using modules inside your Bicep templates. In the example below, I’m referencing the module stored in the ACR that creates the Azure Virtual Desktop resources.
Today, you already have the ability in VScode to view the source of the module; simply hit F12, and you are provided with the source.
This is, however, the transpiled version based on ARM Templates in JSON. Wouldn’t you rather want to see the Bicep module instead? You now can.
There is an experimental feature called publishSource that you can add to your bicepconfig.json. Afterward, you can add the option — with-source to your publish command.
Based on the header image of this article, what country will I be visiting this month? Reply to this post with your answer to win a copy of my book!
When you now press F12 you can see the original Bicep module containing our AVD resources! 💪 When you hover over the file name, you can see the source location, the ACR, module name, and version.
This makes working with Aure Container Registries a lot more convenient!
📖 Looking to get started with Bicep? I authored and published the book Getting started with Bicep: Infrastructure as code on Azure