Skip to content

Commit ef73f05

Browse files
committed
ARM/Bicep mapValue function
1 parent 6dfda4c commit ef73f05

File tree

4 files changed

+100
-0
lines changed

4 files changed

+100
-0
lines changed

articles/azure-resource-manager/bicep/bicep-functions-lambda.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,43 @@ The output from the preceding example is:
163163

164164
**dogNames** shows the dog names from the array of objects; **sayHi** concatenates "Hello" and each of the dog names; and **mapObject** creates another array of objects.
165165

166+
## mapValue
167+
168+
`mapValue(inputObject, lambda expression)`
169+
170+
Creates an object from an input object, using a lambda expression to map values.
171+
172+
Namespace: [sys](bicep-functions.md#namespaces-for-functions).
173+
174+
### Parameters
175+
176+
| Parameter | Required | Type | Description |
177+
|:--- |:--- |:--- |:--- |
178+
| inputObject |Yes |object |The object to map.|
179+
| lambda expression |Yes |expression |The lambda expression used to map the values.|
180+
181+
### Return value
182+
183+
An object.
184+
185+
### Example
186+
187+
The following example shows how to use the `mapValue` function.
188+
189+
```bicep
190+
var newObject = mapValues({ foo: 'foo', bar: 'bar' }, val => toUpper(val))
191+
192+
output mapObject object = newObject
193+
```
194+
195+
The output from the preceding example is:
196+
197+
| Name | Type | Value |
198+
| ---- | ---- | ----- |
199+
| mapObject | Object | {foo: 'FOO', bar: 'BAR'} |
200+
201+
**mapObject** creates another object with the values in upper case.
202+
166203
## reduce
167204

168205
`reduce(inputArray, initialValue, lambda expression)`

articles/azure-resource-manager/bicep/bicep-functions.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,10 @@ The following functions are available for working with lambda expressions. All o
9292

9393
* [filter](bicep-functions-lambda.md#filter)
9494
* [map](bicep-functions-lambda.md#map)
95+
* [mapValue](bicep-functions-lambda.md#mapvalue)
9596
* [reduce](bicep-functions-lambda.md#reduce)
9697
* [sort](bicep-functions-lambda.md#sort)
98+
* [toObject](bicep-functions-lambda.md#toobject)
9799

98100
## Logical functions
99101

articles/azure-resource-manager/templates/template-functions-lambda.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,54 @@ The output from the preceding example is:
227227

228228
**dogNames** shows the dog names from the array of objects; **sayHi** concatenates "Hello" and each of the dog names; and **mapObject** creates another array of objects.
229229

230+
## mapValue
231+
232+
`mapValue(inputObject, lambda expression)`
233+
234+
Creates an object from an input object, using a lambda expression to map values.
235+
236+
Namespace: [sys](bicep-functions.md#namespaces-for-functions).
237+
238+
### Parameters
239+
240+
| Parameter | Required | Type | Description |
241+
|:--- |:--- |:--- |:--- |
242+
| inputObject |Yes |object |The object to map.|
243+
| lambda expression |Yes |expression |The lambda expression used to map the values.|
244+
245+
### Return value
246+
247+
An object.
248+
249+
### Example
250+
251+
The following example shows how to use the `mapValue` function.
252+
253+
```bicep
254+
{
255+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
256+
"contentVersion": "1.0.0.0",
257+
"variables": {
258+
"newObject": "[mapValues(createObject('foo', 'foo', 'bar', 'bar'), lambda('val', toUpper(lambdaVariables('val'))))]"
259+
},
260+
"resources": [],
261+
"outputs": {
262+
"mapObject": {
263+
"type": "object",
264+
"value": "[variables('newObject')]"
265+
}
266+
}
267+
}
268+
```
269+
270+
The output from the preceding example is:
271+
272+
| Name | Type | Value |
273+
| ---- | ---- | ----- |
274+
| mapObject | Object | {foo: 'FOO', bar: 'BAR'} |
275+
276+
**mapObject** creates another object with the values in upper case.
277+
230278
## reduce
231279

232280
`reduce(inputArray, initialValue, lambda function)`

articles/azure-resource-manager/templates/template-functions.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,19 @@ For Bicep files, use the [deployment](../bicep/bicep-functions-deployment.md) fu
121121
<a id="not" aria-hidden="true"></a>
122122
<a id="or" aria-hidden="true"></a>
123123

124+
## Lambda functions
125+
126+
The following functions are available for working with lambda expressions:
127+
128+
* [filter](template-functions-lambda.md#filter)
129+
* [map](template-functions-lambda.md#map)
130+
* [mapValue](template-functions-lambda.md#mapvalue)
131+
* [reduce](template-functions-lambda.md#reduce)
132+
* [sort](template-functions-lambda.md#sort)
133+
* [toObject](template-functions-lambda.md#toobject)
134+
135+
For Bicep files, use the [lambda](../bicep/bicep-functions-lamda.md) functions.
136+
124137
## Logical functions
125138

126139
Resource Manager provides the following functions for working with logical conditions:

0 commit comments

Comments
 (0)