Skip to content

Commit 8735d9f

Browse files
committed
incorporate Jonny's comments
1 parent 637e684 commit 8735d9f

File tree

4 files changed

+148
-119
lines changed

4 files changed

+148
-119
lines changed

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

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,7 @@ For arrays, the function iterates through each element in the first parameter an
947947

948948
For objects, property names and values from the first parameter are added to the result. For later parameters, any new names are added to the result. If a later parameter has a property with the same name, that value overwrites the existing value. The order of the properties isn't guaranteed.
949949

950-
The union function merges not only the top-level elements but also recursively merging any nested arrays and objects within them. See the second example in the following section.
950+
The union function merges not only the top-level elements but also recursively merges any nested objects within them. Nested array values are not merged. See the second example in the following section.
951951

952952
### Example
953953

@@ -992,43 +992,60 @@ The output from the preceding example with the default values is:
992992
The following example shows the deep merge capability:
993993

994994
```bicep
995-
param firstObject object = {
995+
var firstObject = {
996996
property: {
997997
one: 'a'
998998
two: 'b'
999999
three: 'c1'
10001000
}
1001+
nestedArray: [
1002+
1
1003+
2
1004+
]
10011005
}
1002-
1003-
param secondObject object = {
1006+
var secondObject = {
10041007
property: {
10051008
three: 'c2'
10061009
four: 'd'
10071010
five: 'e'
10081011
}
1012+
nestedArray: [
1013+
3
1014+
4
1015+
]
10091016
}
1010-
1011-
param firstArray array = [
1012-
['one', 'two']
1013-
['three']
1017+
var firstArray = [
1018+
[
1019+
'one'
1020+
'two'
1021+
]
1022+
[
1023+
'three'
1024+
]
10141025
]
1015-
1016-
param secondArray array = [
1017-
['three']
1018-
['four', 'two']
1026+
var secondArray = [
1027+
[
1028+
'three'
1029+
]
1030+
[
1031+
'four'
1032+
'two'
1033+
]
10191034
]
10201035
10211036
output objectOutput object = union(firstObject, secondObject)
10221037
output arrayOutput array = union(firstArray, secondArray)
10231038
```
10241039

1025-
The output from the preceding example with the default values is:
1040+
The output from the preceding example is:
10261041

10271042
| Name | Type | Value |
10281043
| ---- | ---- | ----- |
1029-
| objectOutput | Object |{"property":{"one":"a","two":"b","three":"c2","four":"d","five":"e"}}|
1044+
| objectOutput | Object |{"property":{"one":"a","two":"b","three":"c2","four":"d","five":"e"},"nestedArray":[3,4]}|
10301045
| arrayOutput | Array |[["one","two"],["three"],["four","two"]]|
10311046

1047+
If nested arrays were merged, then the value of **objectOutput.nestedArray** would be [1, 2, 3, 4], and the value of **arrayOutput** would be [["one", "two", "three"], ["three", "four", "two"]].
1048+
10321049
## Next steps
10331050

10341051
* To get an array of string values delimited by a value, see [split](./bicep-functions-string.md#split).

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

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ For arrays, the function iterates through each element in the first parameter an
413413

414414
For objects, property names and values from the first parameter are added to the result. For later parameters, any new names are added to the result. If a later parameter has a property with the same name, that value overwrites the existing value. The order of the properties isn't guaranteed.
415415

416-
The union function merges not only the top-level elements but also recursively merging any nested arrays and objects within them. See the second example in the following section.
416+
The union function merges not only the top-level elements but also recursively merges any nested objects within them. Nested array values are not merged. See the second example in the following section.
417417

418418
### Example
419419

@@ -458,43 +458,59 @@ The output from the preceding example with the default values is:
458458
The following example shows the deep merge capability:
459459

460460
```bicep
461-
param firstObject object = {
461+
var firstObject = {
462462
property: {
463463
one: 'a'
464464
two: 'b'
465465
three: 'c1'
466466
}
467+
nestedArray: [
468+
1
469+
2
470+
]
467471
}
468-
469-
param secondObject object = {
472+
var secondObject = {
470473
property: {
471474
three: 'c2'
472475
four: 'd'
473476
five: 'e'
474477
}
478+
nestedArray: [
479+
3
480+
4
481+
]
475482
}
476-
477-
param firstArray array = [
478-
['one', 'two']
479-
['three']
483+
var firstArray = [
484+
[
485+
'one'
486+
'two'
487+
]
488+
[
489+
'three'
490+
]
480491
]
481-
482-
param secondArray array = [
483-
['three']
484-
['four', 'two']
492+
var secondArray = [
493+
[
494+
'three'
495+
]
496+
[
497+
'four'
498+
'two'
499+
]
485500
]
486501
487502
output objectOutput object = union(firstObject, secondObject)
488503
output arrayOutput array = union(firstArray, secondArray)
489504
```
490505

491-
The output from the preceding example with the default values is:
506+
The output from the preceding example is:
492507

493508
| Name | Type | Value |
494509
| ---- | ---- | ----- |
495-
| objectOutput | Object |{"property":{"one":"a","two":"b","three":"c2","four":"d","five":"e"}}|
510+
| objectOutput | Object |{"property":{"one":"a","two":"b","three":"c2","four":"d","five":"e"},"nestedArray":[3,4]}|
496511
| arrayOutput | Array |[["one","two"],["three"],["four","two"]]|
497512

513+
If nested arrays were merged, then the value of **objectOutput.nestedArray** would be [1, 2, 3, 4], and the value of **arrayOutput** would be [["one", "two", "three"], ["three", "four", "two"]].
498514

499515
## Next steps
500516

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

Lines changed: 44 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ For arrays, the function iterates through each element in the first parameter an
721721

722722
For objects, property names and values from the first parameter are added to the result. For later parameters, any new names are added to the result. If a later parameter has a property with the same name, that value overwrites the existing value. The order of the properties isn't guaranteed.
723723

724-
The union function merges not only the top-level elements but also recursively merging any nested arrays and objects within them. See the second example in the following section.
724+
The union function merges not only the top-level elements but also recursively merges any nested objects within them. Nested array values are not merged. See the second example in the following section.
725725

726726
### Example
727727

@@ -742,73 +742,71 @@ The following example shows the deep merge capability:
742742
{
743743
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
744744
"contentVersion": "1.0.0.0",
745-
"parameters": {
745+
"variables": {
746746
"firstObject": {
747-
"type": "object",
748-
"defaultValue": {
749-
"property": {
750-
"one": "a",
751-
"two": "b",
752-
"three": "c1"
753-
}
754-
}
747+
"property": {
748+
"one": "a",
749+
"two": "b",
750+
"three": "c1"
751+
},
752+
"nestedArray": [
753+
1,
754+
2
755+
]
755756
},
756757
"secondObject": {
757-
"type": "object",
758-
"defaultValue": {
759-
"property": {
760-
"three": "c2",
761-
"four": "d",
762-
"five": "e"
763-
}
764-
}
765-
},
766-
"firstArray": {
767-
"type": "array",
768-
"defaultValue": [
769-
[
770-
"one",
771-
"two"
772-
],
773-
[
774-
"three"
775-
]
758+
"property": {
759+
"three": "c2",
760+
"four": "d",
761+
"five": "e"
762+
},
763+
"nestedArray": [
764+
3,
765+
4
776766
]
777767
},
778-
"secondArray": {
779-
"type": "array",
780-
"defaultValue": [
781-
[
782-
"three"
783-
],
784-
[
785-
"four",
786-
"two"
787-
]
768+
"firstArray": [
769+
[
770+
"one",
771+
"two"
772+
],
773+
[
774+
"three"
788775
]
789-
}
776+
],
777+
"secondArray": [
778+
[
779+
"three"
780+
],
781+
[
782+
"four",
783+
"two"
784+
]
785+
]
790786
},
791787
"resources": [],
792788
"outputs": {
793789
"objectOutput": {
794-
"type": "object",
795-
"value": "[union(parameters('firstObject'), parameters('secondObject'))]"
790+
"type": "Object",
791+
"value": "[union(variables('firstObject'), variables('secondObject'))]"
796792
},
797793
"arrayOutput": {
798-
"type": "array",
799-
"value": "[union(parameters('firstArray'), parameters('secondArray'))]"
794+
"type": "Array",
795+
"value": "[union(variables('firstArray'), variables('secondArray'))]"
800796
}
801797
}
802798
}
803799
```
804800

805-
The output from the preceding example with the default values is:
801+
The output from the preceding example is:
806802

807803
| Name | Type | Value |
808804
| ---- | ---- | ----- |
809-
| objectOutput | Object |{"property":{"one":"a","two":"b","three":"c2","four":"d","five":"e"}}|
805+
| objectOutput | Object |{"property":{"one":"a","two":"b","three":"c2","four":"d","five":"e"},"nestedArray":[3,4]}|
810806
| arrayOutput | Array |[["one","two"],["three"],["four","two"]]|
811807

808+
If nested arrays were merged, then the value of **objectOutput.nestedArray** would be [1, 2, 3, 4], and the value of **arrayOutput** would be [["one", "two", "three"], ["three", "four", "two"]].
809+
812810
## Next steps
813811

814812
* For a description of the sections in an ARM template, see [Understand the structure and syntax of ARM templates](./syntax.md).

0 commit comments

Comments
 (0)