How to escape single quote in ARM template

In DevOps release pipeline, for APIM policy, use & quote; to escape quotes within an expression,

<when condition='@(context.Variables.GetValueOrDefault&lt;bool&gt;(&quot;isAuthOk&quot;))' />

I've worked around this with a variable:

"variables": {
    "singleQuote": "'",
},
...
"settings": {
    "fileUris": [],
    "commandToExecute": "[concat('/bin/bash -c ', variables('singleQuote'), 'echo \"export DOCKER_HOST=:2375\" >> /home/', parameters('adminUsername') ,'/.profile', variables('singleQuote'))]",
}

It isn't elegant but it works.


You escape Azure ARM functions in the same way as with VB strings: you simply double the single quote characters.

[concat('This is a ''quoted'' word.')]

outputs

This is a 'quoted' word.

Double quotes still needs to be escaped from JSON.

 [concat('''single'' and \"double\" quotes.')]

outputs

'single' and "double" quotes.