Skip to content

Commit 0deebc2

Browse files
Merge pull request #274984 from mumian/0509-function-mapvalue
ARM/Bicep mapValues function
2 parents 9bbe261 + 252a538 commit 0deebc2

File tree

4 files changed

+95
-2
lines changed

4 files changed

+95
-2
lines changed

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

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Bicep functions - lambda
33
description: Describes the lambda functions to use in a Bicep file.
44
ms.topic: conceptual
55
ms.custom: devx-track-bicep
6-
ms.date: 01/25/2024
6+
ms.date: 05/13/2024
77
---
88
# Lambda functions for Bicep
99

@@ -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+
## mapValues
167+
168+
`mapValues(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 `mapValues` function.
188+
189+
```bicep
190+
var inputObject = { foo: 'foo', bar: 'bar' }
191+
192+
output mapObject object = mapValues(inputObject, val => toUpper(val))
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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ 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#mapvalues)
9596
* [reduce](bicep-functions-lambda.md#reduce)
9697
* [sort](bicep-functions-lambda.md#sort)
9798
* [toObject](bicep-functions-lambda.md#toobject)

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

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Template functions - lambda
33
description: Describes the lambda functions to use in an Azure Resource Manager template (ARM template)
44
ms.topic: conceptual
55
ms.custom: devx-track-arm-template
6-
ms.date: 01/25/2024
6+
ms.date: 05/13/2024
77
---
88

99
# Lambda functions for ARM templates
@@ -227,6 +227,57 @@ 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+
## mapValues
231+
232+
`mapValues(inputObject, lambda expression)`
233+
234+
Creates an object from an input object, using a lambda expression to map values.
235+
236+
In Bicep, use the [mapValues](../bicep/bicep-functions-lambda.md#mapvalues) function.
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 `mapValues` function.
252+
253+
```json
254+
{
255+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
256+
"contentVersion": "1.0.0.0",
257+
"variables": {
258+
"inputObject": {
259+
"foo": "foo",
260+
"bar": "bar"
261+
}
262+
},
263+
"resources": [],
264+
"outputs": {
265+
"mapObject": {
266+
"type": "object",
267+
"value": "[mapValues(variables('inputObject'), lambda('val', toUpper(lambdaVariables('val'))))]"
268+
}
269+
}
270+
}
271+
```
272+
273+
The output from the preceding example is:
274+
275+
| Name | Type | Value |
276+
| ---- | ---- | ----- |
277+
| mapObject | Object | {foo: 'FOO', bar: 'BAR'} |
278+
279+
**mapObject** creates another object with the values in upper case.
280+
230281
## reduce
231282

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

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ For Bicep files, use the [deployment](../bicep/bicep-functions-deployment.md) fu
131131

132132
<a id="filter" aria-hidden="true"></a>
133133
<a id="map" aria-hidden="true"></a>
134+
<a id="mapValues" aria-hidden="true"></a>
134135
<a id="reduce" aria-hidden="true"></a>
135136
<a id="sort" aria-hidden="true"></a>
136137
<a id="toObject" aria-hidden="true"></a>
@@ -141,10 +142,13 @@ Resource Manager provides the following functions for working with lambda expres
141142

142143
* [filter](template-functions-lambda.md#filter)
143144
* [map](template-functions-lambda.md#map)
145+
* [mapValues](template-functions-lambda.md#mapvalues)
144146
* [reduce](template-functions-lambda.md#reduce)
145147
* [sort](template-functions-lambda.md#sort)
146148
* [toObject](template-functions-lambda.md#toobject)
147149

150+
For Bicep files, use the [lambda](../bicep/bicep-functions-lambda.md) functions.
151+
148152
<a id="and" aria-hidden="true"></a>
149153
<a id="bool" aria-hidden="true"></a>
150154
<a id="false" aria-hidden="true"></a>

0 commit comments

Comments
 (0)