5

When I try to deploy variable to Azure Automation assets, I got and error and can't deploy my resource.

Suppose this template

{
   "name": "myVariable",
   "type": "Microsoft.Automation/automationAccounts/variables",
   "apiVersion": "2015-10-31",
   "dependsOn": [
      "[resourceId('Microsoft.Automation/automationAccounts', variables('automationAccountName'))]"
   ],
   "location": "[variables('automationLocation')]",
   "properties": {
      "isEncrypted": "false",
      "value": "8f703df8-0448-4ee3-8629-fc3f01840683"
    }
}

Deployment throw me the exception :

{\"Message\":\"The request is invalid.\",\"ModelState\":{\"variable.properties.value\":[\"Invalid JSON primitive: a7d14fb0-232e-4fa0-a748-c7c8fb2082e2.\"]}}

I have also try with :

"value": "\"8f703df8-0448-4ee3-8629-fc3f01840683\""

But any attempt fail!

Anyone know how to provisioning Variable Assets with ARM template ?

Francis
  • 486
  • 3
  • 21

2 Answers2

3

Looking at the examples you should escape the quotes:

{
  "name": "sampleVariable",
  "properties": {
    "value": "\"ComputerName.domain.com\"",
    "description": "my description",
    "isEncrypted": false
  }
}

Reference

4c74356b41
  • 69,186
  • 6
  • 100
  • 141
0

If you are trying to populate the "value" key with an ARM variable or parameter, you will need to concatenate the double quotes.

{
  "name": "myVariable",
  "type": "variables",
  "apiVersion": "2015-10-31",
  "properties": {
    "value": "[concat('\"', parameters('myVariableValue'), '\"')]"
   },
   "dependsOn": [
     "[resourceId('Microsoft.Automation/automationAccounts/', parameters('automationAccountName'))]"
   ]
}
JordanBean
  • 1,949
  • 21
  • 28