An individual .bicep
file is composed of the following declarations, in any order. Each declaration must be separated from the next by at minimum a single new line.
Spaces and tabs are ignored when authoring Bicep files. New lines however have semantic meaning, for example in object and array declarations.
Single line comments begin with //
.
var myVar = 'hi!' // this is a comment
Multi-line comments are declared between /*
and */
characters.
/* this
is a
multi line comment */
var myVar = 'hi!' /* so is
this */
Strings are defined by a sequence of characters between single quote ('
) characters, and must be declared on a single line.
The following are the set of reserved characters which must be escaped by a backslash (\
) character:
Escape Sequence | Represented value | Notes |
---|---|---|
\\ |
\ |
|
\' |
' |
|
\n |
line feed (LF) |
|
\r |
carriage return (CR) |
|
\t |
tab character |
|
\$ |
$ |
Only needs to be escaped if it is followed by { |
All strings in Bicep support interpolation, in order to reference expressions in-place. To inject an expression, surround it by ${
and }
. Expressions that are referenced cannot span multiple lines.
// myVar evaluates to "hello!"
var myVar = 'hello!'
// myVar evaluates to "what's up?"
var myVar2 = 'what\'s up?'
// myVar evaluates to "hello steve!"
var name = 'steve'
var myVar3 = 'hello ${name}!'
Number literals are formatted as integers - a list of digits optionally preceeded by a -
. Floating point, decimal or binary formats are not currently supported.
var myVar = 123
var myVar2 = -454
var mvVar3 = 0
Boolean literals consist of the keywords true
and false
var myVar = false
var myVar2 = true
Arrays are declared using the open and close square bracket characters ([
and ]
), and consist of a set of values. Each value pair must be on a new line, and there must be a new line after the opening bracket and before the closing bracket. The values may consist of either a literal or an expression.
Note that commas are not required or permitted between array values.
var myArray = [
5983
3923
-241
]
var myEmptyArray = [
]
var myMixedArray = [
myVariable
'hello!'
true
1255
]
Objects are declared using the open and close brace characters ({
and }
), and consist of a set of keys and values. Each key/value pair must be on a new line, and there must be a new line after the opening brace and before the closing brace. Keys and values are separated with the colon (:
) character.
Keys must either be a sequence of alphanumeric characters, or an uninterpolated string in cases where special characters are needed. Values may consist of any literal or an expression.
Note that commas are not required or permitted between object property pairs.
var myObj = {
stringProp: 'hello!'
boolProp: false
numberProp: -464
objProp: {
nestedString: 'hello nested!'
}
arrayProp: [
1234
3435
]
variableProp: myVariable
}
var myObjWithSpecialChars = {
'$special\tchars!': true
normalKey: 'val'
}
var myEmptyObj = {
}
Null may be declared using the keyword null
var myVar = null