Bicep CLI commands

This article describes the commands you can use in the Bicep CLI. You must have the Bicep CLI installed to run the commands.

You can either run the Bicep CLI commands through Azure CLI or by calling Bicep directly. This article shows how to run the commands in Azure CLI. When running through Azure CLI, you start the commands with az. If you're not using Azure CLI, run the commands without az at the start of the command. For example, az bicep build becomes bicep build.


The build command converts a Bicep file to an Azure Resource Manager template (ARM template). Typically, you don't need to run this command because it runs automatically when you deploy a Bicep file. Run it manually when you want to see the ARM template JSON that is created from your Bicep file.

The following example converts a Bicep file named main.bicep to an ARM template named main.json. The new file is created in the same directory as the Bicep file.

az bicep build --file main.bicep

The next example saves main.json to a different directory.

az bicep build --file main.bicep --outdir c:\jsontemplates

The next example specifies the name and location of the file to create.

az bicep build --file main.bicep --outfile c:\jsontemplates\azuredeploy.json

To print the file to stdout, use:

az bicep build --file main.bicep --stdout

If your Bicep file includes a module that references an external registry, the build command automatically calls restore. The restore command gets the file from the registry and stores it in the local cache.


The restore command doesn't refresh the cache. For more information, see restore.

To not call restore automatically, use the --no-restore switch:

az bicep build --no-restore <bicep-file>

The build process with the --no-restore switch fails if one of the external modules isn't already cached:

The module with reference "" has not been restored.

When you get this error, either run the build command without the --no-restore switch or run bicep restore first.

To use the --no-restore switch, you must have Bicep CLI version 0.4.1008 or later.


The decompile command converts ARM template JSON to a Bicep file.

az bicep decompile --file main.json

The command creates a file named main.bicep in the same directory as main.json. If main.bicep exists in the same directory, use the --force switch to overwrite the existing Bicep file.

For more information about using this command, see Decompiling ARM template JSON to Bicep.


The generate-params command builds .parameters.json file from the given bicep file, updates if there is an existing parameters.json file.

az bicep generate-params --file main.bicep

The command creates a parameter file named main.parameters.json. The parameter file only contains the parameters without default values configured in the Bicep file.


The install command adds the Bicep CLI to your local environment. For more information, see Install Bicep tools. This command is only available through Azure CLI.

To install the latest version, use:

az bicep install

To install a specific version:

az bicep install --version v0.3.255


The list-versions command returns all available versions of the Bicep CLI. Use this command to see if you want to upgrade or install a new version. This command is only available through Azure CLI.

az bicep list-versions

The command returns an array of available versions.



The publish command adds a module to a registry. The Azure container registry must exist and the account publishing to the registry must have the correct permissions. For more information about setting up a module registry, see Use private registry for Bicep modules.

After publishing the file to the registry, you can reference it in a module.

To use the publish command, you must have Bicep CLI version 0.4.1008 or later.

To publish a module to a registry, use:

az bicep publish --file <bicep-file> --target br:<registry-name><module-path>:<tag>

For example:

az bicep publish --file storage.bicep --target

The publish command doesn't recognize aliases that you've defined in a bicepconfig.json file. Provide the full module path.


Publishing to the same target overwrites the old module. We recommend that you increment the version when updating.


When your Bicep file uses modules that are published to a registry, the restore command gets copies of all the required modules from the registry. It stores those copies in a local cache. A Bicep file can only be built when the external files are available in the local cache. Typically, you don't need to run restore because it's called automatically by build.

To restore external modules to the local cache, the account must have the correct permissions to access the registry. You can configure the credential precedence for authenticating to the registry in the Bicep config file.

To use the restore command, you must have Bicep CLI version 0.4.1008 or later. This command is currently only available when calling the Bicep CLI directly. It's not currently available through the Azure CLI command.

To manually restore the external modules for a file, use:

bicep restore <bicep-file> [--force]

The Bicep file you provide is the file you wish to deploy. It must contain a module that links to a registry. For example, you can restore the following file:

module stgModule '' = {
  name: 'storageDeploy'
  params: {
    storagePrefix: 'examplestg1'

The local cache is found in:

  • On Windows

  • On Linux


The restore command doesn't refresh the cache if a module is already cached. To fresh the cache, you can either delete the module path from the cache or use the --force switch with the restore command.


The upgrade command updates your installed version with the latest version. This command is only available through Azure CLI.

az bicep upgrade


The version command returns your installed version.

az bicep version

The command shows the version number.

Bicep CLI version 0.4.1008 (223b8d227a)

To call this command directly through the Bicep CLI, use:

bicep --version

If you haven't installed Bicep CLI, you see an error indicating Bicep CLI wasn't found.

Next steps

To learn about deploying a Bicep file, see: