Dhruv Kapoor
Dhruv Kapoor

Reputation: 332

How do I escape an opening square bracket in an ARM template?

I have something like the following under properties for an application settings configuration:

"my_setting" : "[{width:1, height:2}]"

I want exactly the string contained in the value (including the square brackets) to appear on the application settings. Unfortunately, the opening square bracket indicates a function and the deployment throws me an exception due to it. How can I escape the beginning square bracket?

Upvotes: 5

Views: 3233

Answers (2)

bmoore-msft
bmoore-msft

Reputation: 8737

The escape sequence for ARM templates is the left bracket itself (i.e. just put two together)

"my_setting" : "[[{width:1, height:2}]"

Upvotes: 13

Tom Sun
Tom Sun

Reputation: 24569

How can I escape the beginning square bracket?

We could use the concat function to avoid to using the special characters

"variables": {
   ...
    "left": "[",
    "right": "]",
    ...
  },

Please have a try to use following code. It works correctly on my side.

"my_setting": "[concat(variables('left'),'{width:1, height:2}',variables('right'))]",

Upvotes: 1

Related Questions