Azure Portal: languageVersion 2.0 `nullable` parameters are incorrectly marked as required
- Dominant language
- Bicep
- Stars
- 3.6k
- Forks
- 830
- Avg merge
- 1d 21m
- Merged PRs (30d)
- 79
Description
A parameter that is marked as `nullable` by using `?` in the Bicep template will be incorrectly shown by the Azure Portal as a _required_ parameter. (This is in the new functionality that was just introduced by the update that fixes #11096.)
To reproduce, publish the following (minimal but complete) Bicep template to a Template Spec and then try to deploy that Template Spec from the Portal:
```bicep
param test string?
output test string = test ?? 'nothinghere'
```
You will notice that the Portal shows an `*` next to the parameter called `Test`, indicating that it is a required parameter. It will not accept leaving the input field empty, and refuse to deploy the template. There is no way to get the template output to be the string `nothinghere` (other than to supply exactly that string in the input field obviously).
Transpiling that template to ARM gives the following result. This is also the template that's shown when viewing the contents of the Template Spec.
```json
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"languageVersion": "2.0",
"contentVersion": "1.0.0.0",
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.26.54.24096",
"templateHash": "15022646283098480590"
}
},
"parameters": {
"test": {
"type": "string",
"nullable": true
}
},
"resources": {},
"outputs": {
"test": {
"type": "string",
"value": "[coalesce(parameters('test'), 'nothinghere')]"
}
}
}
```
Contributor guide
Research direction
Reproduce the issue by publishing the provided Bicep template as a Template Spec, then inspect the generated ARM JSON and deploy it from the Azure Portal. Confirm that the nullable `test` parameter is treated as optional and that leaving it empty allows deployment with the `nothinghere` output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, json
- Domain
- cloud
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100