Azure / Azure/azure-quickstart-templates
Add bool() template function
- Dominant language
- Bicep
- Stars
- 14.9k
- Forks
- 16.2k
- Avg merge
- 6d 21h
- Merged PRs (30d)
- 6
Description
Any plans to provide an ARM template function that converts a value to a bool?
```
bool(valueToConvert)
```
where valueToConvert can be any type of value, including objects and array
This is really useful when you have a parameter that when not set (defaultValue: "") you want to pick one value, and when set you want to pick another value. I have multiple examples of where I use this type of functionality. You can accomplish this today, but boy is it ugly (see below).
``` javascript
"parameters": {
"ipAddress": {
"type": "string",
"defaultValue": ""
}
},
"variables": {
"ipAddressHasValue": "[length(trim(substring(padLeft(parameters('ipAddress'), 1, ' '), 0, 1)))]",
"convertToPrivateAllocationMethod": [
"Dynamic",
"Static"
],
"privateAllocationMethod": "[variables('convertToPrivateAllocationMethod')[variables('ipAddressHasValue')]]",
"convertToPrivateIpAddress": [
null,
"[parameters('ipAddress')]"
],
"privateIpAddress": "[variables('converToPrivateIpAddress')[variables('ipAddressHasValue')]]"
},
"resources": [
{
...
"type": "Microsoft.Network/networkInterfaces",
"properties": {
...
"ipConfigurations": [
{
...
"properties": {
"privateIPAddress": "[variables('privateIpAddress')]",
"privateIPAllocationMethod": "[variables('privateAllocationMethod')]",
...
}
}
]
}
}
]
```
Contributor guide
No contributing guide indexed for this repository
Research direction
The issue provides no repository file, test, or implementation entry point. Start by locating the ARM template function catalog and expression evaluation tests, then determine where a bool(valueToConvert) function would be specified and validated. Done means the function accepts the stated value types and has coverage for the requested conversions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure
- Domain
- cloud, infrastructure
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100