Bicep Config File
Bicep Config File

Azure Bicep – What is Bicep Configuration File ?

In previous article, I have briefly mentioned about customizing the Bicep Linter ruleset by adding a bicep configuration file. In this article, we are going to discuss about this file in detail.

What does this file contain ?

A bicep configuration file has name bicepconfig.json. This file contains the settings to customize your development experience.

We already have discussed in previous article, that we can customize our linter ruleset by using this file. We can also define the aliases for module paths in this file. Thus, we do not need to setup the path again and again in the bicep file.

We can also specify the credential precedence for Azure account authentication from Azure Bicep and VS Code. The credentials are used to publish modules to registries and to restore external modules to the local cache when using the insert resource function.

Where to place this file ?

This file can be placed in a directory where the bicep files are stored. If you have a repository, which contains multiple folders (nested / siblings), then you can create multiple bicep config files, if really needed. If you have multiple bicepconfig.json files, then the config file , which is closed to the bicep file in the directory hierarchy is used.

To create a bicepconfig.json file, we can open the folder in Visual Studio Code and then hit CTRL + SHIFT + P and then select Bicep: Create Bicep Configuration File

Azure Bicep – Creating a bicepconfig.json file

Bicep extension for Visual Studio code supports intellisense for bicepconfig.json. It can be used to try this file and figure out which all settings are available in the file.

Credentials

We can configure the credentials to be used by Bicep in order to authenticate with a registry. By default, it uses credentials of the already logged in user from Azure CLI or AZ PowerShell. But the Bicep deploy command from Visual Studio code uses Azure Account extension in order to authenticate with Azure.

The available credential types are:

  • AzureCLI
  • AzurePowerShell
  • Environment
  • ManagedIdentity
  • VisualStudio
  • VisualStudioCode

These can be used to specify the credential precedence in the JSON file as shown in the code snippet given below.

Module Aliases

We can add a module aliases element in the config file. This has two child elements

  • br – for specifying aliases of bicep registry. We can add as many aliases as needed.
  • ts – for specifying template spec aliases. We can add as many aliases as needed.

Each bicep registry alias has two properties:

  • registry (required): registry login server name
  • modulePath (optional): registry repository where the modules are stored

Each template spec can have two properties:

  • subscription (required): the subscription ID that hosts the template specs
  • resourceGroup (required): the name of the resource group that contains the template specs

I hope this provides enough information to get you started on the bicep config file. Let me know your thoughts.

Leave a ReplyCancel reply