Skip to content

Commit 481ad19

Browse files
committed
move items() to the Bicep object function file
1 parent 7492349 commit 481ad19

File tree

3 files changed

+119
-119
lines changed

3 files changed

+119
-119
lines changed

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

Lines changed: 1 addition & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Describes the functions to use in a Bicep file for working with arr
44
author: mumian
55
ms.topic: conceptual
66
ms.author: jgao
7-
ms.date: 12/08/2021
7+
ms.date: 04/06/2022
88

99
---
1010
# Array functions for Bicep
@@ -328,120 +328,6 @@ The output from the preceding example is:
328328
| commonUp | array | [1, 2, 3] |
329329
| commonDown | array | [3, 2, 1] |
330330

331-
## items
332-
333-
`items(object)`
334-
335-
Converts a dictionary object to an array.
336-
337-
Namespace: [sys](bicep-functions.md#namespaces-for-functions).
338-
339-
### Parameters
340-
341-
| Parameter | Required | Type | Description |
342-
|:--- |:--- |:--- |:--- |
343-
| object |Yes |object |The dictionary object to convert to an array. |
344-
345-
### Return value
346-
347-
An array of objects for the converted dictionary. Each object in the array has a `key` property that contains the key value for the dictionary. Each object also has a `value` property that contains the properties for the object.
348-
349-
### Example
350-
351-
The following example converts a dictionary object to an array. For each object in the array, it creates a new object with modified values.
352-
353-
```bicep
354-
var entities = {
355-
item002: {
356-
enabled: false
357-
displayName: 'Example item 2'
358-
number: 200
359-
}
360-
item001: {
361-
enabled: true
362-
displayName: 'Example item 1'
363-
number: 300
364-
}
365-
}
366-
367-
var modifiedListOfEntities = [for entity in items(entities): {
368-
key: entity.key
369-
fullName: entity.value.displayName
370-
itemEnabled: entity.value.enabled
371-
}]
372-
373-
output modifiedResult array = modifiedListOfEntities
374-
```
375-
376-
The preceding example returns:
377-
378-
```json
379-
"modifiedResult": {
380-
"type": "Array",
381-
"value": [
382-
{
383-
"fullName": "Example item 1",
384-
"itemEnabled": true,
385-
"key": "item001"
386-
},
387-
{
388-
"fullName": "Example item 2",
389-
"itemEnabled": false,
390-
"key": "item002"
391-
}
392-
]
393-
}
394-
```
395-
396-
The following example shows the array that is returned from the items function.
397-
398-
```bicep
399-
var entities = {
400-
item002: {
401-
enabled: false
402-
displayName: 'Example item 2'
403-
number: 200
404-
}
405-
item001: {
406-
enabled: true
407-
displayName: 'Example item 1'
408-
number: 300
409-
}
410-
}
411-
412-
var entitiesArray = items(entities)
413-
414-
output itemsResult array = entitiesArray
415-
```
416-
417-
The example returns:
418-
419-
```json
420-
"itemsResult": {
421-
"type": "Array",
422-
"value": [
423-
{
424-
"key": "item001",
425-
"value": {
426-
"displayName": "Example item 1",
427-
"enabled": true,
428-
"number": 300
429-
}
430-
},
431-
{
432-
"key": "item002",
433-
"value": {
434-
"displayName": "Example item 2",
435-
"enabled": false,
436-
"number": 200
437-
}
438-
}
439-
]
440-
}
441-
```
442-
443-
The items() function sorts the objects in the alphabetical order. For example, **item001** appears before **item002** in the outputs of the two preceding samples.
444-
445331
## last
446332

447333
`last(arg1)`

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

Lines changed: 115 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Describes the functions to use in a Bicep file for working with obj
44
author: mumian
55
ms.author: jgao
66
ms.topic: conceptual
7-
ms.date: 09/30/2021
7+
ms.date: 04/06/2022
88
---
99

1010
# Object functions for Bicep
@@ -162,6 +162,120 @@ The output from the preceding example with the default values is:
162162
| objectOutput | Object | {"one": "a", "three": "c"} |
163163
| arrayOutput | Array | ["two", "three"] |
164164

165+
## items
166+
167+
`items(object)`
168+
169+
Converts a dictionary object to an array.
170+
171+
Namespace: [sys](bicep-functions.md#namespaces-for-functions).
172+
173+
### Parameters
174+
175+
| Parameter | Required | Type | Description |
176+
|:--- |:--- |:--- |:--- |
177+
| object |Yes |object |The dictionary object to convert to an array. |
178+
179+
### Return value
180+
181+
An array of objects for the converted dictionary. Each object in the array has a `key` property that contains the key value for the dictionary. Each object also has a `value` property that contains the properties for the object.
182+
183+
### Example
184+
185+
The following example converts a dictionary object to an array. For each object in the array, it creates a new object with modified values.
186+
187+
```bicep
188+
var entities = {
189+
item002: {
190+
enabled: false
191+
displayName: 'Example item 2'
192+
number: 200
193+
}
194+
item001: {
195+
enabled: true
196+
displayName: 'Example item 1'
197+
number: 300
198+
}
199+
}
200+
201+
var modifiedListOfEntities = [for entity in items(entities): {
202+
key: entity.key
203+
fullName: entity.value.displayName
204+
itemEnabled: entity.value.enabled
205+
}]
206+
207+
output modifiedResult array = modifiedListOfEntities
208+
```
209+
210+
The preceding example returns:
211+
212+
```json
213+
"modifiedResult": {
214+
"type": "Array",
215+
"value": [
216+
{
217+
"fullName": "Example item 1",
218+
"itemEnabled": true,
219+
"key": "item001"
220+
},
221+
{
222+
"fullName": "Example item 2",
223+
"itemEnabled": false,
224+
"key": "item002"
225+
}
226+
]
227+
}
228+
```
229+
230+
The following example shows the array that is returned from the items function.
231+
232+
```bicep
233+
var entities = {
234+
item002: {
235+
enabled: false
236+
displayName: 'Example item 2'
237+
number: 200
238+
}
239+
item001: {
240+
enabled: true
241+
displayName: 'Example item 1'
242+
number: 300
243+
}
244+
}
245+
246+
var entitiesArray = items(entities)
247+
248+
output itemsResult array = entitiesArray
249+
```
250+
251+
The example returns:
252+
253+
```json
254+
"itemsResult": {
255+
"type": "Array",
256+
"value": [
257+
{
258+
"key": "item001",
259+
"value": {
260+
"displayName": "Example item 1",
261+
"enabled": true,
262+
"number": 300
263+
}
264+
},
265+
{
266+
"key": "item002",
267+
"value": {
268+
"displayName": "Example item 2",
269+
"enabled": false,
270+
"number": 200
271+
}
272+
}
273+
]
274+
}
275+
```
276+
277+
The items() function sorts the objects in the alphabetical order. For example, **item001** appears before **item002** in the outputs of the two preceding samples.
278+
165279
<a id="json"></a>
166280

167281
## json

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Bicep functions
33
description: Describes the functions to use in a Bicep file to retrieve values, work with strings and numerics, and retrieve deployment information.
44
ms.topic: conceptual
5-
ms.date: 10/15/2021
5+
ms.date: 04/06/2022
66
---
77

88
# Bicep functions
@@ -19,7 +19,7 @@ All Bicep functions are contained within two namespaces - `az` and `sys`. Typica
1919
// Parameter contains the same name as a function
2020
param range int
2121
22-
// Must use sys namespace to call the function.
22+
// Must use sys namespace to call the function.
2323
// The second use of range refers to the parameter.
2424
output result array = sys.range(1, range)
2525
```
@@ -40,7 +40,6 @@ The following functions are available for working with arrays. All of these func
4040
* [empty](./bicep-functions-array.md#empty)
4141
* [first](./bicep-functions-array.md#first)
4242
* [intersection](./bicep-functions-array.md#intersection)
43-
* [items](./bicep-functions-array.md#items)
4443
* [last](./bicep-functions-array.md#last)
4544
* [length](./bicep-functions-array.md#length)
4645
* [min](./bicep-functions-array.md#min)
@@ -92,6 +91,7 @@ The following functions are available for working with objects. All of these fun
9291
* [contains](./bicep-functions-object.md#contains)
9392
* [empty](./bicep-functions-object.md#empty)
9493
* [intersection](./bicep-functions-object.md#intersection)
94+
* [items](./bicep-functions-object.md#items)
9595
* [json](./bicep-functions-object.md#json)
9696
* [length](./bicep-functions-object.md#length)
9797
* [union](./bicep-functions-object.md#union)

0 commit comments

Comments
 (0)