How to Declare a Parameter with Bicep

In Azure, Bicep helps us declare and manage our Azure resources. It provides an easy-to-use, declarative syntax for creating and managing Azure resources. In this blog post, we will show you how to use Bicep to declare parameters for your Azure resources.

Creating a Parameter

To create a parameter in Bicep, we need to use the parm keyword with the parameter’s name and the type. The example below shows a declaration of a parameter with a string type.

param servername string

We can also assign the declared parameter a default value that will be assigned if a value is not passed to the template.

param servername string = 'web'

Parameter Types

Bicep supports the following parameter types:

  • string
  • int
  • bool
  • array \ object

We use the following code to pass a parameter value to the Bicep template.

az deployment group create --name deploy --template-file file.bicep --resource-group bicep --parameters servername=server2022

Published
Categorized as Bicep

Leave a comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.