Description
When deploying via ARM/Bicep templates, the Microsoft.Automation/automationAccounts/variables
API (all versions as of this date) don't properly handle the properties.value
, which is listed in the API docs as a type string
.
For example, with this template:
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "Microsoft.Automation/automationAccounts/variables",
"name": "Start-Stop-VMs-Test/myVariableName",
"apiVersion": "2015-10-31",
"location": "westeurope",
"properties": {
"description": "myVariableDesc",
"value": "myVariableValue"
}
}
]
}
You get this error:
{"code":"DeploymentFailed","message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.","details":[{"code":"BadRequest","message":"{\"Message\":\"The request is invalid.\",\"ModelState\":{\"variable.properties.value\":[\"Invalid JSON primitive: myVariableValue.\"]}}"}]}
The issue seems to be that it's stripping the quotes off of the input JSON and exposing the raw string.
A temporary workaround is to wrap the string in extra quotes. These 3 approaches work:
"\"myVariableValue\""
- "'myVariableValue'"
- concat('"', myVariable, '"')