Bicep - New Line and Strings
Bicep - New Line and Strings

Azure Bicep – New Lines and Multi-Line Strings in Bicep Files

In past few articles, I have been trying to write about Azure Bicep. While working on those articles, I have experienced few things about new lines. In this short article, I will try to write down what I experienced.

Whitespaces

Actually, multiple tabs or whitespaces are ignored by bicep. Hence, if does not matter how many whitespaces / tabs are being used on a line of code. I thought not not including this point in this article, but I finally included it here, because many of us may have used YAML files and they are sensitive to whitespaces. So, just wanted to explicitly state that bicep file ignore the extra whitespaces placed in the file.

Comments

If you know about C# programming language, the comments in bicep are almost same. Single line comment should be prefixed with // (double slash )characters. On the other hands, multi-line comments can also be added to the bicep file, but they should start with /* and should end with */.

New Lines

A bicep file is new line sensitive. So, the two resource elements specified in the code snippet given below are not the same.

Multi-Line strings

This is an interesting thing considering the bicep is new line sensitive. Generally we specify strings inside single quotes on the same line, but if you trying to declare a string value which spans over multiple lines, then you cannot use single quotes.

The multi-line strings should be enclosed between three single quotes as shown in the code snippet given below. Depending on encoding of the file, the new lines will be treated as \r\n or \n.

If the there is a new line character immediately after the ”’ (three single quotes), then that new line character is ignored. String interpolation does not seem to be supported yet.

I hope you find this information helpful. Let me know your thoughts.

Leave a Reply Cancel reply