LinuxCommandLibrary

az-bicep

Deploy Azure resources using Bicep files

TLDR

Install Bicep CLI

$ az bicep install
copy

Build a Bicep file
$ az bicep build [[-f|--file]] [path/to/file.bicep]
copy

Attempt to decompile an ARM template file to a Bicep file
$ az bicep decompile [[-f|--file]] [path/to/template_file.json]
copy

Upgrade Bicep CLI to the latest version
$ az bicep upgrade
copy

Display the installed version of Bicep CLI
$ az bicep version
copy

List all available versions of Bicep CLI
$ az bicep list-versions
copy

Uninstall Bicep CLI
$ az bicep uninstall
copy

SYNOPSIS

az bicep <SUBCOMMAND> [--debug] [--help] [--output FORMAT] [--query JMESPATH] [--subscription ID] [--verbose]

PARAMETERS

--debug
    Increase logging verbosity to show all debug logs.

--help -h
    Show help message and exit.

--only-show-errors
    Only show errors, suppressing warnings.

--output -o
    Output format: json|jsonc|table|tsv|yaml|yamlc|none (default: none).

--query
    JMESPath query string for output filtering.

--subscription
    Name or ID of Azure subscription.

--verbose
    Increase logging verbosity (use --debug for full logs).

DESCRIPTION

az bicep is a command group in the Azure CLI for working with Bicep, a declarative language for deploying Azure infrastructure. Bicep simplifies authoring Azure Resource Manager (ARM) templates using a concise syntax, avoiding complex JSON.

Key capabilities include:
build: Compiles .bicep files to ARM JSON templates for deployment.
decompile: Reverse-engineers ARM JSON back to readable Bicep code.
lint: Checks Bicep files for style, best practices, and errors.
publish: Uploads Bicep modules to Azure Template Specs for reuse.
restore: Downloads external modules and caches them locally.
• Other subcommands: install, outline, test, version.

Ideal for CI/CD pipelines, local testing, and modular infrastructure code. Requires Azure CLI 2.28+ and authentication via az login. Enhances productivity over raw ARM templates.

CAVEATS

Requires Azure CLI 2.28+ and az login. Some subcommands need standalone Bicep CLI via az bicep install. Not all features available in older versions.

SUBCOMMANDS

build, decompile, install, lint, outline, publish, restore, test, version.

EXAMPLE

az bicep build main.bicep --outfile main.json
az bicep lint main.bicep

HISTORY

Introduced in Azure CLI 2.28.0 (Nov 2021) alongside Bicep v0.4. Evolved with Bicep releases; now supports modules, linting, and testing for better IaC workflows.

SEE ALSO

az deployment(1), az group deployment(1), bicep(1)

Copied to clipboard