Raw New Markdown
Generating updated version of doc...
Rendered New Markdown
Generating updated version of doc...
---
title: Bicep CLI commands
description: Learn about the commands that you can use in the Bicep CLI. These commands include building JSON Azure Resource Manager templates from Bicep.
ms.topic: reference
ms.date: 11/30/2026
ms.custom: devx-track-azurecli, devx-track-bicep, devx-track-arm-template
---
# Bicep CLI commands
This article describes the commands you can use in the Bicep CLI.
You can run Bicep commands in two ways:
- **Standalone Bicep CLI**: Run `bicep <command>`. You must [install the Bicep CLI manually](./install.md#install-manually). Azure PowerShell also uses the standalone Bicep CLI.
- **Azure CLI**: Run `az bicep <command>`. The Azure CLI [installs and manages its own copy](./install.md#azure-cli) of the Bicep CLI, and doesn't add it to your `PATH`. For the full list of Azure CLI parameters, see [az bicep](/cli/azure/bicep).
The two interfaces use different syntax. The standalone Bicep CLI takes the input file as a positional argument, while the Azure CLI requires the `--file` parameter:
| Standalone Bicep CLI | Azure CLI |
|---|---|
| `bicep build main.bicep` | `az bicep build --file main.bicep` |
| `bicep lint main.bicep` | `az bicep lint --file main.bicep` |
| `bicep --version` | `az bicep version` |
| Not available | `az bicep install`, `az bicep upgrade`, `az bicep list-versions`, `az bicep uninstall` |
Some standalone options, such as `--pattern` and `--config`, don't have an `az bicep` equivalent. To use them from the Azure CLI, use [`az bicep run`](/cli/azure/bicep#az-bicep-run) (Azure CLI 2.88.0 or later) to pass the command directly to the Bicep CLI:
```azurecli
az bicep run --command "build main.bicep --config ./bicepconfig.prod.json"
```
## Common options
### Global options
The following options are available on the `bicep` command itself:
| Option | Description |
|---|---|
| `--version`, `-v` | Shows the Bicep CLI version. |
| `--help`, `-h`, `-?` | Shows help. Add it after any command to show help for that command, for example `bicep build --help`. |
| `--license` | Prints license information. |
| `--third-party-notices` | Prints third-party notices. |
### Process multiple files
The `build`, `build-params`, `format`, `lint`, and `restore` commands accept a `--pattern` option that processes every file matching a glob pattern instead of a single input file. Specify either an input file or `--pattern`, not both. Quote the pattern so that your shell doesn't expand it:
```bicepcli
bicep build --pattern './**/*.bicep'
bicep lint --pattern './modules/*.bicep'
```
The pattern is resolved relative to the current directory. When you use `--pattern`:
- `--stdout` and `--outfile` aren't supported.
- `build` and `build-params` support `--outdir`, and preserve the relative folder structure of the matched files under the output directory.
- `format` doesn't support `--outdir` and formats each matched file in place.
The Azure CLI `az bicep` commands don't support `--pattern`. Use `az bicep run` instead.
### Output diagnostics as SARIF
The `build`, `build-params`, and `lint` commands accept `--diagnostics-format` with a value of `default` or `sarif`. Use `sarif` to produce diagnostics as a [SARIF 2.1.0](https://docs.oasis-open.org/sarif/sarif/v2.1.0/sarif-v2.1.0.html) log that code-scanning tools can consume:
```bicepcli
bicep lint main.bicep --diagnostics-format sarif > lint.sarif
```
The `lint` command writes the SARIF log to standard output. The `build` command writes the SARIF log to standard error.
In the Azure CLI, only `az bicep lint` supports `--diagnostics-format`.
### Use a specific configuration file
Starting in Bicep CLI v0.49, most commands accept `--config <path>` to use a specific configuration file instead of automatic _bicepconfig.json_ discovery:
```bicepcli
bicep build main.bicep --config ./bicepconfig.prod.json
```
The `az bicep` commands don't support `--config`. Use `az bicep run` instead. For details about how the configuration file is applied, see [Specify a configuration file in the Bicep CLI](./bicep-config.md#specify-a-configuration-file-in-the-bicep-cli).
### Control output location
Commands that write files accept the following options. Unless noted otherwise, the output file is written next to the input file with the same base name.
| Option | Description |
|---|---|
| `--outdir <dir>` | Writes the output file to the specified directory. |
| `--outfile <path>` | Writes the output to the specified file path. |
| `--stdout` | Prints the output to standard output instead of writing a file. |
### Restore external modules
Commands that compile Bicep files automatically [restore](#restore) modules that reference an external registry. Use `--no-restore` to skip the restore. The command fails if an external module isn't already in the local cache:
```error
The module with reference "br:exampleregistry.azurecr.io/bicep/modules/storage:v1" hasn't been restored.
```
When you get this error, either run the command without `--no-restore` or run `bicep restore` first.
## build
The `build` command converts a Bicep file to a JSON 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 JSON ARM template that's created from your Bicep file.
Using any of the following Bicep features automatically enables language version 2.0 code generation:
* [user-defined types](../bicep/user-defined-data-types.md)
* [user-defined functions](../bicep/user-defined-functions.md)
* [compile-time imports](../bicep/bicep-import.md)
* [experimental features](../bicep/bicep-config.md#enable-experimental-features)
```bicepcli
bicep build [<bicep-file>] [options]
```
| Option | Description |
|---|---|
| `--outdir`, `--outfile`, `--stdout` | Control where the template is written. See [Control output location](#control-output-location). |
| `--pattern <glob>` | Builds all files that match the pattern. See [Process multiple files](#process-multiple-files). |
| `--no-restore` | Builds without restoring external modules. |
| `--diagnostics-format <default\|sarif>` | Sets the diagnostics format. |
| `--config <path>` | Uses the specified configuration file. |
The following example converts a Bicep file named _main.bicep_ to an ARM template named _main.json_ in the same directory:
# [Bicep CLI](#tab/bicep-cli)
```bicepcli
bicep build main.bicep
```
# [Azure CLI](#tab/azure-cli)
```azurecli
az bicep build --file main.bicep
```
---
The next example saves _main.json_ to a different directory:
# [Bicep CLI](#tab/bicep-cli)
```bicepcli
bicep build main.bicep --outdir c:\jsontemplates
```
# [Azure CLI](#tab/azure-cli)
```azurecli
az bicep build --file main.bicep --outdir c:\jsontemplates
```
---
The following example specifies the name and location of the file to create:
# [Bicep CLI](#tab/bicep-cli)
```bicepcli
bicep build main.bicep --outfile c:\jsontemplates\azuredeploy.json
```
# [Azure CLI](#tab/azure-cli)
```azurecli
az bicep build --file main.bicep --outfile c:\jsontemplates\azuredeploy.json
```
---
To print the template to `stdout`, use:
# [Bicep CLI](#tab/bicep-cli)
```bicepcli
bicep build main.bicep --stdout
```
# [Azure CLI](#tab/azure-cli)
```azurecli
az bicep build --file main.bicep --stdout
```
---
To build every Bicep file under the current directory and write the templates to a _build_ directory, use [`--pattern`](#process-multiple-files):
# [Bicep CLI](#tab/bicep-cli)
```bicepcli
bicep build --pattern './**/*.bicep' --outdir ./build
```
# [Azure CLI](#tab/azure-cli)
`az bicep build` doesn't support `--pattern`. Use `az bicep run` to pass the command directly to the Bicep CLI:
```azurecli
az bicep run --command "build --pattern './**/*.bicep' --outdir ./build"
```
---
If your Bicep file includes a module that references an external registry, the `build` command automatically calls [`restore`](#restore). To prevent automatic restore, use `--no-restore`. For more information, see [Restore external modules](#restore-external-modules).
## build-params
The `build-params` command builds a `.bicepparam` file into a JSON parameters file.
```bicepcli
bicep build-params [<bicepparam-file>] [options]
```
| Option | Description |
|---|---|
| `--outdir`, `--outfile` | Control where the JSON parameters file is written. Only the parameters file is written; the referenced Bicep file isn't included. |
| `--stdout` | Prints both the compiled parameters and the compiled template that the `using` declaration references. See [Standard output format](#standard-output-format). |
| `--pattern <glob>` | Builds all files that match the pattern. See [Process multiple files](#process-multiple-files). |
| `--bicep-file <path>` | Verifies that the specified Bicep file matches the file in the `using` declaration. The command fails if the files don't match. This option doesn't change which Bicep file is used. |
| `--no-restore` | Builds without restoring external modules. |
| `--diagnostics-format <default\|sarif>` | Sets the diagnostics format. |
| `--config <path>` | Uses the specified configuration file. |
The following example converts a _params.bicepparam_ parameters file into a _params.json_ JSON parameters file:
# [Bicep CLI](#tab/bicep-cli)
```bicepcli
bicep build-params params.bicepparam
```
# [Azure CLI](#tab/azure-cli)
```azurecli
az bicep build-params --file params.bicepparam
```
---
The following example writes the JSON parameters file to a specific path:
# [Bicep CLI](#tab/bicep-cli)
```bicepcli
bicep build-params params.bicepparam --outfile ./out/params.json
```
# [Azure CLI](#tab/azure-cli)
```azurecli
az bicep build-params --file params.bicepparam --outfile ./out/params.json
```
---
### Standard output format
With `--stdout`, the command prints a JSON object instead of a plain parameters file. Use this output when you need both the parameters and the template, for example in a deployment script:
```json
{
"parametersJson": "{\"$schema\": \"https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#\", ...}",
"templateJson": "{\"$schema\": \"https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#\", ...}",
"templateSpecId": null
}
```
| Property | Description |
|---|---|
| `parametersJson` | The compiled parameters file, serialized as a JSON string. |
| `templateJson` | The compiled template that the `using` declaration references, serialized as a JSON string. |
| `templateSpecId` | The resource ID of the template spec when the `using` declaration references one; otherwise `null`. |
Because `parametersJson` and `templateJson` are strings, parse them separately. For example, in PowerShell:
```powershell
$output = bicep build-params params.bicepparam --stdout | ConvertFrom-Json
$parameters = $output.parametersJson | ConvertFrom-Json
```
## console
The `console` command is available in Bicep CLI v0.42.1 or later. It opens an interactive Read-Eval-Print Loop (REPL) where you can evaluate Bicep expressions, declare variables, and test functions and user-defined types without deploying. It also accepts piped or redirected input.
```bicepcli
bicep console [--config <path>]
```
To exit the console, press `ESC` or enter `exit`. The `console` command isn't available in the Azure CLI.
For features, limitations, and examples, see [Evaluate expressions with the Bicep console](./bicep-console.md).
## decompile
The `decompile` command converts a JSON ARM template to a Bicep file.
```bicepcli
bicep decompile [<json-file>] [options]
```
| Option | Description |
|---|---|
| `--outdir`, `--outfile`, `--stdout` | Control where the Bicep file is written. See [Control output location](#control-output-location). |
| `--force` | Overwrites the output file if it exists. Without this option, the command fails if the output file exists. |
# [Bicep CLI](#tab/bicep-cli)
```bicepcli
bicep decompile main.json
```
# [Azure CLI](#tab/azure-cli)
```azurecli
az bicep decompile --file main.json
```
---
This 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.
`az bicep decompile` supports only `--force`. To use the output options from the Azure CLI, use `az bicep run`.
For more information about using this command, see [Decompile JSON ARM template to Bicep](decompile.md).
## decompile-params
The `decompile-params` command decompiles a JSON parameters file to a `.bicepparam` parameters file.
```bicepcli
bicep decompile-params <json-file> [options]
```
| Option | Description |
|---|---|
| `--bicep-file <path>` | The Bicep file, relative to the `.bicepparam` file, to reference in the `using` declaration. |
| `--outdir`, `--outfile`, `--stdout` | Control where the `.bicepparam` file is written. See [Control output location](#control-output-location). |
| `--force` | Overwrites the output file if it exists. |
# [Bicep CLI](#tab/bicep-cli)
```bicepcli
bicep decompile-params azuredeploy.parameters.json --bicep-file ./dir/main.bicep
```
# [Azure CLI](#tab/azure-cli)
```azurecli
az bicep decompile-params --file azuredeploy.parameters.json --bicep-file ./dir/main.bicep
```
---
This command decompiles an _azuredeploy.parameters.json_ parameters file into an _azuredeploy.parameters.bicepparam_ file.
## format
The `format` command formats a Bicep file so that it follows the recommended style conventions. Think of it as a code formatter or "prettier" for your Bicep files. It has the same function as the `SHIFT+ALT+F` shortcut in Visual Studio Code.
By default, the command formats the file in place.
```bicepcli
bicep format [<bicep-file>] [options]
```
| Option | Description |
|---|---|
| `--outdir`, `--outfile`, `--stdout` | Write the formatted file somewhere other than the input file. See [Control output location](#control-output-location). |
| `--pattern <glob>` | Formats all matching files in place. See [Process multiple files](#process-multiple-files). |
| `--newline-kind <LF\|CRLF\|CR>` | Sets the line-ending characters. |
| `--indent-kind <Space\|Tab>` | Sets the indentation kind. |
| `--indent-size <number>` | Sets the number of spaces for each indentation level. Valid only when `--indent-kind` is `Space`. |
| `--insert-final-newline` | Inserts a final newline at the end of the file. |
| `--config <path>` | Uses the specified configuration file. |
# [Bicep CLI](#tab/bicep-cli)
```bicepcli
bicep format main.bicep
```
# [Azure CLI](#tab/azure-cli)
```azurecli
az bicep format --file main.bicep
```
---
The following example formats a file with two-space indentation and LF line endings, and prints the result instead of changing the file:
# [Bicep CLI](#tab/bicep-cli)
```bicepcli
bicep format main.bicep --indent-kind Space --indent-size 2 --newline-kind LF --stdout
```
# [Azure CLI](#tab/azure-cli)
```azurecli
az bicep format --file main.bicep --indent-kind Space --indent-size 2 --newline-kind LF --stdout
```
---
To format every Bicep file under the current directory, use:
```bicepcli
bicep format --pattern './**/*.bicep'
```
## generate-params
The `generate-params` command builds a parameters file from the given Bicep file.
```bicepcli
bicep generate-params [<bicep-file>] [options]
```
| Option | Description |
|---|---|
| `--output-format <json\|bicepparam>` | Sets the format of the parameters file. The default is `json`. |
| `--include-params <requiredonly\|all>` | Sets which parameters to include. `requiredonly`, the default, includes only parameters without a default value. `all` also includes parameters that have a default value. |
| `--outdir`, `--outfile`, `--stdout` | Control where the parameters file is written. See [Control output location](#control-output-location). |
| `--no-restore` | Generates the file without restoring external modules. |
| `--config <path>` | Uses the specified configuration file. |
By default, the output file is named _\<bicep-file-name>.parameters.json_ for JSON output, or _\<bicep-file-name>.bicepparam_ for `.bicepparam` output.
If a JSON parameters file already exists at the output path, the command keeps the values that are already in the file. When the output format is `bicepparam`, the command regenerates the file, and values in an existing `.bicepparam` file aren't kept.
# [Bicep CLI](#tab/bicep-cli)
```bicepcli
bicep generate-params main.bicep --output-format bicepparam --include-params all
```
# [Azure CLI](#tab/azure-cli)
```azurecli
az bicep generate-params --file main.bicep --output-format bicepparam --include-params all
```
---
This command creates a Bicep parameters file named _main.bicepparam_. The parameters file contains all parameters in the Bicep file, whether configured with default values or not.
# [Bicep CLI](#tab/bicep-cli)
```bicepcli
bicep generate-params main.bicep --outfile main.parameters.json
```
# [Azure CLI](#tab/azure-cli)
```azurecli
az bicep generate-params --file main.bicep --outfile main.parameters.json
```
---
This command creates a parameters file named _main.parameters.json_. The parameters file only contains the parameters without default values configured in the Bicep file.
## jsonrpc
The `jsonrpc` command launches the Bicep CLI with a JSON-RPC interface, enabling fast programmatic interaction with Bicep files.
```bicepcli
bicep jsonrpc --pipe <named-pipe>
bicep jsonrpc --socket <tcp-port>
bicep jsonrpc --stdio
```
For the wire format, available methods, and connection options, see [Programmatic Bicep usage with JSON-RPC](bicep-cli-jsonrpc.md).
## lint
The `lint` command returns the errors and [linter rule](./linter.md) violations of a Bicep file.
```bicepcli
bicep lint [<bicep-file>] [options]
```
| Option | Description |
|---|---|
| `--pattern <glob>` | Lints all files that match the pattern. See [Process multiple files](#process-multiple-files). |
| `--no-restore` | Lints without restoring external modules. |
| `--diagnostics-format <default\|sarif>` | Sets the diagnostics format. With `sarif`, the SARIF log is written to standard output. |
| `--config <path>` | Uses the specified configuration file. |
The command returns exit code `1` if any diagnostic has the `error` level, and `0` otherwise. To make a linter rule fail the command, set its level to `error` in the [linter configuration](./bicep-config-linter.md).
# [Bicep CLI](#tab/bicep-cli)
```bicepcli
bicep lint main.bicep
```
# [Azure CLI](#tab/azure-cli)
```azurecli
az bicep lint --file main.bicep
```
---
To lint every Bicep file under the current directory, use [`--pattern`](#process-multiple-files):
# [Bicep CLI](#tab/bicep-cli)
```bicepcli
bicep lint --pattern './**/*.bicep'
```
# [Azure CLI](#tab/azure-cli)
`az bicep lint` doesn't support `--pattern`. Use `az bicep run` to pass the command directly to the Bicep CLI:
```azurecli
az bicep run --command "lint --pattern './**/*.bicep'"
```
---
The following example saves the results as a SARIF log, for example to upload to a code-scanning tool in a CI pipeline:
# [Bicep CLI](#tab/bicep-cli)
```bicepcli
bicep lint main.bicep --diagnostics-format sarif > lint.sarif
```
# [Azure CLI](#tab/azure-cli)
```azurecli
az bicep lint --file main.bicep --diagnostics-format sarif
```
---
To lint a file with a specific Bicep configuration file (Bicep CLI v0.49 or later), use `--config`:
# [Bicep CLI](#tab/bicep-cli)
```bicepcli
bicep lint main.bicep --config ./eng/common/bicepconfig.json
```
# [Azure CLI](#tab/azure-cli)
```azurecli
az bicep run --command "lint main.bicep --config ./eng/common/bicepconfig.json"
```
---
If your Bicep file includes a module that references an external registry, the `lint` command automatically calls [`restore`](#restore). To prevent automatic restore, use `--no-restore`. For more information, see [Restore external modules](#restore-external-modules).
## publish
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](private-module-registry.md). You can configure the profile and credential precedence for authenticating to the registry in the [Bicep config file](./bicep-config-modules.md#configure-profiles-and-credentials).
After publishing the file to the registry, you can [reference it in a module](modules.md#file-in-registry).
```bicepcli
bicep publish <bicep-file> --target <module-reference> [options]
```
| Option | Description |
|---|---|
| `--target <module-reference>` | Required. The registry location to publish to, for example `br:<registry-name>.azurecr.io/<module-path>:<tag>`. |
| `--documentation-uri <uri>` | A URI for the module's documentation. Must be an absolute URI. |
| `--force` | Overwrites the module if the target tag already exists. |
| `--no-restore` | Publishes without restoring external modules. |
| `--config <path>` | Uses the specified configuration file. |
To publish a module to a registry, use:
# [Bicep CLI](#tab/bicep-cli)
```bicepcli
bicep publish storage.bicep --target br:exampleregistry.azurecr.io/bicep/modules/storage:v1 --documentation-uri https://www.contoso.com/exampleregistry.html
```
# [Azure CLI](#tab/azure-cli)
```azurecli
az bicep publish --file storage.bicep --target br:exampleregistry.azurecr.io/bicep/modules/storage:v1 --documentation-uri https://www.contoso.com/exampleregistry.html
```
---
If you define a [registry alias](bicep-config-modules.md#aliases-for-modules) in your _bicepconfig.json_ file, you can use the alias in the target:
```bicepcli
bicep publish storage.bicep --target br/CoreModules:storage:v1
```
If the target tag already exists, the command fails. To overwrite the existing module, use `--force`. Because the cached copy of a module isn't refreshed until a consumer forces a restore, different users can end up with different versions of an overwritten tag. Prefer publishing a new tag when you change a module.
# [Bicep CLI](#tab/bicep-cli)
```bicepcli
bicep publish storage.bicep --target br:exampleregistry.azurecr.io/bicep/modules/storage:v1 --force
```
# [Azure CLI](#tab/azure-cli)
```azurecli
az bicep publish --file storage.bicep --target br:exampleregistry.azurecr.io/bicep/modules/storage:v1 --force
```
---
## restore
When your Bicep file uses modules that you publish 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.
You don't need to call `restore` explicitly. Commands that compile Bicep files, such as `build`, `build-params`, `lint`, and `publish`, restore any missing modules automatically, as do deployments from the Azure CLI and Azure PowerShell. Run `restore` explicitly when you want to download modules in a separate step, for example before running other commands with `--no-restore`, or to refresh cached modules with `--force`.
To restore external modules to the local cache, the account must have the correct profile and permissions to access the registry. You can configure the [profile and credential precedence](./bicep-config-modules.md#configure-profiles-and-credentials) for authenticating to the registry in the Bicep config file.
```bicepcli
bicep restore [<bicep-file>] [options]
```
| Option | Description |
|---|---|
| `--pattern <glob>` | Restores modules for all files that match the pattern. See [Process multiple files](#process-multiple-files). |
| `--force` | Restores modules even if they're already cached, and retries modules that previously failed to restore. |
| `--config <path>` | Uses the specified configuration file. |
To manually restore the external modules for a file, use:
# [Bicep CLI](#tab/bicep-cli)
```bicepcli
bicep restore main.bicep
```
# [Azure CLI](#tab/azure-cli)
```azurecli
az bicep restore --file main.bicep
```
---
To restore the modules for every Bicep file under the current directory, use [`--pattern`](#process-multiple-files):
# [Bicep CLI](#tab/bicep-cli)
```bicepcli
bicep restore --pattern './**/*.bicep'
```
# [Azure CLI](#tab/azure-cli)
`az bicep restore` doesn't support `--pattern`. Use `az bicep run` to pass the command directly to the Bicep CLI:
```azurecli
az bicep run --command "restore --pattern './**/*.bicep'"
```
---
The Bicep file you provide is the file you want to deploy. It must contain a module that links to a registry. For example, you can restore the following file:
```bicep
module stgModule 'br:exampleregistry.azurecr.io/bicep/modules/storage:v1' = {
name: 'storageDeploy'
params: {
storagePrefix: 'examplestg1'
}
}
```
You find the local cache in:
* On Windows
```path
%USERPROFILE%\.bicep\br\<registry-name>.azurecr.io\<module-path>\<tag>
```
* On Linux
```path
/home/<username>/.bicep
```
* On Mac
```path
~/.bicep
```
The `restore` command doesn't refresh the cache if a module is already cached. To refresh the cache, you can either delete the module path from the cache or use the `--force` switch:
# [Bicep CLI](#tab/bicep-cli)
```bicepcli
bicep restore main.bicep --force
```
# [Azure CLI](#tab/azure-cli)
```azurecli
az bicep restore --file main.bicep --force
```
---
## snapshot
The `snapshot` command, available in Bicep CLI v0.41.2 or later, creates a normalized, deterministic representation of the resources that a `.bicepparam` file deploys. You can compare the snapshot with later versions of your code to check what a refactor changes, without deploying anything to Azure. The evaluation runs locally, although restoring external modules can require network access.
For a walkthrough of creating baselines, testing refactors, and validating snapshots in CI, see [Test Bicep changes with snapshots](./snapshots.md).
```bicepcli
bicep snapshot <bicepparam-file> [options]
```
| Option | Description |
|---|---|
| `--mode <overwrite\|validate>` | `overwrite`, the default, writes the snapshot file. `validate` compares the current code with the existing snapshot file. |
| `--subscription-id`, `--resource-group`, `--location`, `--tenant-id`, `--management-group-id`, `--deployment-name` | Provide deployment context. See [Provide context](#provide-context). |
| `--config <path>` | Uses the specified configuration file. |
### Create a snapshot
The following command writes a `<bicepparam-file-name>.snapshot.json` file next to the `.bicepparam` file:
# [Bicep CLI](#tab/bicep-cli)
```bicepcli
bicep snapshot main.bicepparam --mode overwrite
```
# [Azure CLI](#tab/azure-cli)
Requires Azure CLI 2.90.0 or later.
```azurecli
az bicep snapshot --file main.bicepparam --mode Overwrite
```
---
### Validate changes
In validate mode, the command compares your current code with the saved snapshot and shows the differences. It returns exit code `1` if the snapshot file is missing or if the resources differ, so you can use it as a check in a CI pipeline.
# [Bicep CLI](#tab/bicep-cli)
```bicepcli
bicep snapshot main.bicepparam --mode validate
```
# [Azure CLI](#tab/azure-cli)
Requires Azure CLI 2.90.0 or later.
```azurecli
az bicep snapshot --file main.bicepparam --mode Validate
```
---
A sample output looks like:
```output
Snapshot validation failed. Expected no changes, but found the following:
Scope: <unknown>
~ [format('/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Storage/storageAccounts/stmyappstorage001', subscription().subscriptionId, resourceGroup().name)]
~ apiVersion: "2025-01-01" => "2025-06-01"
~ sku.name: "Standard_LRS" => "Standard_GRS"
```
Snapshots compare your code with a saved baseline. To compare a deployment with the resources that currently exist in Azure, use [what-if](./deploy-what-if.md).
### Provide context
Because the snapshot command doesn't connect to Azure, it can't look up values such as your subscription ID or resource group name. If your code uses environment functions such as `subscription().id`, the snapshot contains unevaluated expressions unless you provide context through the following options:
| Argument | Purpose | Example Value |
| :--- | :--- | :--- |
| `--subscription-id` | Replaces the value returned by `subscription().subscriptionId` | `aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e` |
| `--resource-group` | Replaces the value returned by `resourceGroup().name` | `my-production-rg` |
| `--location` | Supplies `resourceGroup().location` when used with `--resource-group`, or `deployment().location` for deployments above resource-group scope | `westeurope` |
| `--tenant-id` | Replaces the value returned by `tenant().tenantId` | `72f988bf-86f1-41af-91ab-2d7cd011db47` |
| `--management-group-id` | Replaces the value returned by `managementGroup().name` | `my-corp-mg` |
| `--deployment-name` | Replaces the value returned by `deployment().name` | `snapshot-test` |
# [Bicep CLI](#tab/bicep-cli)
```bicepcli
bicep snapshot main.bicepparam \
--subscription-id 00000000-0000-0000-0000-000000000000 \
--resource-group my-temp-rg \
--location eastus \
--mode overwrite
```
# [Azure CLI](#tab/azure-cli)
```azurecli
az bicep snapshot --file main.bicepparam \
--subscription-id 00000000-0000-0000-0000-000000000000 \
--resource-group my-temp-rg \
--location eastus \
--mode Overwrite
```
The `--subscription-id` and `--tenant-id` values only provide context for the snapshot. They don't change the subscription that the Azure CLI uses.
---
## Azure CLI management commands
The following commands manage the copy of the Bicep CLI that the Azure CLI uses. They're only available in the Azure CLI. For all parameters, see [az bicep](/cli/azure/bicep). For other installation methods, see [Install Bicep tools](install.md).
### install
The `install` command installs the Bicep CLI for use by the Azure CLI. To install the latest version, use:
```azurecli
az bicep install
```
To install a specific version, use the following command:
```azurecli
az bicep install --version v0.49.2
```
### list-versions
The `list-versions` command returns all available versions of the Bicep CLI. Use this command to see if you want to [upgrade](#upgrade) or [install](#install) a new version.
```azurecli
az bicep list-versions
```
The command returns an array of available versions, newest first:
```output
[
"v0.49.2",
"v0.48.1",
...
]
```
### upgrade
The `upgrade` command updates the Bicep CLI that the Azure CLI uses to the latest version.
```azurecli
az bicep upgrade
```
### version
To show the installed version, use:
# [Bicep CLI](#tab/bicep-cli)
```bicepcli
bicep --version
```
If you didn't install the Bicep CLI, you see an error message stating that the Bicep CLI wasn't found.
# [Azure CLI](#tab/azure-cli)
```azurecli
az bicep version
```
---
The command shows the version number:
```output
Bicep CLI version 0.49.2 (b34271ac51)
```
## Next steps
To learn more about deploying a Bicep file, see:
* [Deploy - Azure CLI](deploy-cli.md)
* [Deploy - Azure PowerShell](deploy-powershell.md)
* [Deploy - Cloud Shell](deploy-cloud-shell.md)