I am trying to deploy this ARM template
/* example_template.json */
{
"$schema": "https://schema.management.azure.com/schemas/2019-08-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"var": {
"type": "string",
"defaultValue": "
echo ${VARIABLE}
",
"metadata": {
"description": "some description"
}
}
},
"resources": [],
"outputs": {
"ouput": {
"type": "string",
"value": "[string(parameters('var'))]"
}
}
}
which successfully outputs what I want:
"outputs": {
"ouput": {
"type": "String",
"value": "\n echo ${VARIABLE}\n "
}
}
The problem is, if I am trying to use this in a bash script, $VARIABLE may have a space in it, hence I need to output to be
"outputs": {
"ouput": {
"type": "String",
"value": "\n echo \"${USER}\"\n "
}
}
to prevent argument splitting.
So, I have tried to edit my template to include the quotes
/* example_template.json */
{
"$schema": "https://schema.management.azure.com/schemas/2019-08-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"var": {
"type": "string",
"defaultValue": "
echo \"${VARIABLE}\"
",
"metadata": {
"description": "some description"
}
}
},
"resources": [],
"outputs": {
"ouput": {
"type": "string",
"value": "[string(parameters('var'))]"
}
}
}
Which gives me a validate and create error:
> az deployment group validate -f example_template.json -g resource-group-name
Failed to parse 'example_template.json', please check whether it is a valid JSON format
This seems to only happen with the multi-line string - if I put the whole defaultValue on a single line i.e.,
"defaultValue": "echo \"${VARIABLE}\""
it is successful again.
I need to use a multiline string as this variable is for a long deployment script which would be infeasible to put on one-line.
I believe this is a bug due to the parser only failing with the multiline string, but am unsure where to report it!
Does anyone know what a possible solution to this could be?
Thanks, Akhil