Create Bicep files by using Visual Studio Code

This article shows you how to use Visual Studio Code to create Bicep files.

Install VS Code

To set up your environment for Bicep development, see Install Bicep tools. After completing those steps, you'll have Visual Studio Code and the Bicep extension. You also have either the latest Azure CLI or the latest Azure PowerShell module.

Bicep commands

Visual Studio Code comes with several Bicep commands.

Open or create a Bicep file in VS Code, select the View menu and then select Command Palette. You can also use the key combination [CTRL]+[SHIFT]+P to bring up the command palette. Type Bicep to list the Bicep commands.

Screenshot of Visual Studio Code Bicep commands in the command palette.

These commands include:

These commands are also shown in the context menu when you right-click a Bicep file:

Screenshot of Visual Studio Code Bicep commands in the context menu.

Build Bicep file

The build command converts a Bicep file to an Azure Resource Manager template (ARM template). The new JSON template is stored in the same folder with the same file name. If a file with the same file name exists, it overwrites the old file. For more information, see Bicep CLI commands.

Create Bicep configuration file

The Bicep configuration file (bicepconfig.json) can be used to customize your Bicep development experience. You can add bicepconfig.json in multiple directories. The configuration file closest to the bicep file in the directory hierarchy is used. When you select this command, the extension opens a dialog for you to select a folder. The default folder is where you store the Bicep file. If a bicepconfig.json file already exists in the folder, you have the option to overwrite the existing file.

Deploy Bicep file

You can deploy Bicep files directly from Visual Studio Code. Select Deploy Bicep file from the command palette or from the context menu. The extension prompts you to sign in Azure, select subscription, create/select resource group, and enter parameter values.

Generate parameters file

This command creates a parameter file in the same folder as the Bicep file. The new parameter file name is <bicep-file-name>.parameters.json.

Insert resource

The insert resource command adds a resource declaration in the Bicep file by providing the resource ID of an existing resource. After you select Insert Resource, enter the resource ID in the command palette. It takes a few moments to insert the resource.

You can find the resource ID from the Azure portal, or by using:

az resource list

Similar to exporting templates, the process tries to create a usable resource. However, most of the inserted resources require some modification before they can be used to deploy Azure resources.

For more information, see Decompiling ARM template JSON to Bicep.

Open Bicep visualizer

The visualizer shows the resources defined in the Bicep file with the resource dependency information. The diagram is the visualization of a Linux virtual machine Bicep file.

Visual Studio Code Bicep visualizer

You have the option to open the visualizer side-by-side with the Bicep file.

Restore Bicep file

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. For more information, see restore.

View type document

From Visual Studio Code, you can easily open the template reference for the resource type you are working on. To do so, hover your cursor over the resource symbolic name, and then select View type document.

Screenshot of Visual Studio Code Bicep view type document.

Next steps

To walk through a quickstart, see Quickstart: Create Bicep files with Visual Studio Code.