Azure / Azure/azure-rest-api-specs
Microsoft.Automation/automationAccounts/variables properties.value does not accept strings correctly
- Dominant language
- TypeSpec
- Stars
- 3.1k
- Forks
- 6k
- Avg merge
- 2d 22h
- Merged PRs (30d)
- 444
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`](https://docs.microsoft.com/en-us/azure/templates/microsoft.automation/automationaccounts/variables?tabs=bicep#variablecreateorupdateproperties-object).
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, '"')
[Credit to this StackOverflow post.](https://stackoverflow.com/questions/50124310/azure-template-to-create-automation-account-variable-wont-accept-strings-but-i)
Contributor guide
Research direction
Start by locating the Microsoft.Automation automationAccounts/variables API definition and reviewing properties.value for API version 2015-10-31 and later versions. Reproduce the ARM/Bicep deployment using the JSON example and inspect whether the request preserves the documented string value. Done when normal string input is accepted or the specification clearly records the service limitation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure
- Domain
- api, cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100