Skip to content

Commit 1a0502e

Browse files
committed
Add the deep merge capability information
1 parent b7a0c12 commit 1a0502e

File tree

4 files changed

+239
-8
lines changed

4 files changed

+239
-8
lines changed

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

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
---
22
title: Bicep functions - arrays
33
description: Describes the functions to use in a Bicep file for working with arrays.
4-
author: mumian
54
ms.topic: conceptual
65
ms.custom: devx-track-bicep
7-
ms.author: jgao
8-
ms.date: 12/09/2022
6+
ms.date: 01/11/2024
97
---
108

119
# Array functions for Bicep
@@ -949,6 +947,8 @@ For arrays, the function iterates through each element in the first parameter an
949947

950948
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.
951949

950+
The union function merge 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.
951+
952952
### Example
953953

954954
The following example shows how to use union with arrays and objects:
@@ -989,6 +989,46 @@ The output from the preceding example with the default values is:
989989
| objectOutput | Object | {"one": "a", "two": "b", "three": "c2", "four": "d", "five": "e"} |
990990
| arrayOutput | Array | ["one", "two", "three", "four"] |
991991

992+
The following example shows the deep merge capability:
993+
994+
```bicep
995+
param firstObject object = {
996+
property: {
997+
one: 'a'
998+
two: 'b'
999+
three: 'c1'
1000+
}
1001+
}
1002+
1003+
param secondObject object = {
1004+
property: {
1005+
three: 'c2'
1006+
four: 'd'
1007+
five: 'e'
1008+
}
1009+
}
1010+
1011+
param firstArray array = [
1012+
['one', 'two']
1013+
['three']
1014+
]
1015+
1016+
param secondArray array = [
1017+
['three']
1018+
['four', 'two']
1019+
]
1020+
1021+
output objectOutput object = union(firstObject, secondObject)
1022+
output arrayOutput array = union(firstArray, secondArray)
1023+
```
1024+
1025+
The output from the preceding example with the default values is:
1026+
1027+
| Name | Type | Value |
1028+
| ---- | ---- | ----- |
1029+
| objectOutput | Object |{"property":{"one":"a","two":"b","three":"c2","four":"d","five":"e"}}|
1030+
| arrayOutput | Array |[["one","two"],["three"],["four","two"]]|
1031+
9921032
## Next steps
9931033

9941034
* 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: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
---
22
title: Bicep functions - objects
33
description: Describes the functions to use in a Bicep file for working with objects.
4-
author: mumian
5-
ms.author: jgao
64
ms.topic: conceptual
75
ms.custom: devx-track-bicep
8-
ms.date: 03/19/2023
6+
ms.date: 01/11/2024
97
---
108

119
# Object functions for Bicep
@@ -415,6 +413,8 @@ For arrays, the function iterates through each element in the first parameter an
415413

416414
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.
417415

416+
The union function merge 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.
417+
418418
### Example
419419

420420
The following example shows how to use union with arrays and objects:
@@ -455,6 +455,47 @@ The output from the preceding example with the default values is:
455455
| objectOutput | Object | {"one": "a", "two": "b", "three": "c2", "four": "d", "five": "e"} |
456456
| arrayOutput | Array | ["one", "two", "three", "four"] |
457457

458+
The following example shows the deep merge capability:
459+
460+
```bicep
461+
param firstObject object = {
462+
property: {
463+
one: 'a'
464+
two: 'b'
465+
three: 'c1'
466+
}
467+
}
468+
469+
param secondObject object = {
470+
property: {
471+
three: 'c2'
472+
four: 'd'
473+
five: 'e'
474+
}
475+
}
476+
477+
param firstArray array = [
478+
['one', 'two']
479+
['three']
480+
]
481+
482+
param secondArray array = [
483+
['three']
484+
['four', 'two']
485+
]
486+
487+
output objectOutput object = union(firstObject, secondObject)
488+
output arrayOutput array = union(firstArray, secondArray)
489+
```
490+
491+
The output from the preceding example with the default values is:
492+
493+
| Name | Type | Value |
494+
| ---- | ---- | ----- |
495+
| objectOutput | Object |{"property":{"one":"a","two":"b","three":"c2","four":"d","five":"e"}}|
496+
| arrayOutput | Array |[["one","two"],["three"],["four","two"]]|
497+
498+
458499
## Next steps
459500

460501
* For a description of the sections in a Bicep file, see [Understand the structure and syntax of Bicep files](./file.md).

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

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

99
# Array functions for ARM templates
@@ -721,6 +721,8 @@ 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 merge 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.
725+
724726
### Example
725727

726728
The following example shows how to use union with arrays and objects.
@@ -734,6 +736,79 @@ The output from the preceding example with the default values is:
734736
| objectOutput | Object | {"one": "a", "two": "b", "three": "c2", "four": "d", "five": "e"} |
735737
| arrayOutput | Array | ["one", "two", "three", "four"] |
736738

739+
The following example shows the deep merge capability:
740+
741+
```json
742+
{
743+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
744+
"contentVersion": "1.0.0.0",
745+
"parameters": {
746+
"firstObject": {
747+
"type": "object",
748+
"defaultValue": {
749+
"property": {
750+
"one": "a",
751+
"two": "b",
752+
"three": "c1"
753+
}
754+
}
755+
},
756+
"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+
]
776+
]
777+
},
778+
"secondArray": {
779+
"type": "array",
780+
"defaultValue": [
781+
[
782+
"three"
783+
],
784+
[
785+
"four",
786+
"two"
787+
]
788+
]
789+
}
790+
},
791+
"resources": [],
792+
"outputs": {
793+
"objectOutput": {
794+
"type": "object",
795+
"value": "[union(parameters('firstObject'), parameters('secondObject'))]"
796+
},
797+
"arrayOutput": {
798+
"type": "array",
799+
"value": "[union(parameters('firstArray'), parameters('secondArray'))]"
800+
}
801+
}
802+
}
803+
```
804+
805+
The output from the preceding example with the default values is:
806+
807+
| Name | Type | Value |
808+
| ---- | ---- | ----- |
809+
| objectOutput | Object |{"property":{"one":"a","two":"b","three":"c2","four":"d","five":"e"}}|
810+
| arrayOutput | Array |[["one","two"],["three"],["four","two"]]|
811+
737812
## Next steps
738813

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

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

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Template functions - objects
33
description: Describes the functions to use in an Azure Resource Manager template (ARM template) for working with objects.
44
ms.topic: conceptual
55
ms.custom: devx-track-arm-template
6-
ms.date: 08/22/2023
6+
ms.date: 01/11/2024
77
---
88

99
# Object functions for ARM templates
@@ -437,6 +437,8 @@ For arrays, the function iterates through each element in the first parameter an
437437

438438
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.
439439

440+
The union function merge 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.
441+
440442
### Example
441443

442444
The following example shows how to use union with arrays and objects:
@@ -450,6 +452,79 @@ The output from the preceding example with the default values is:
450452
| objectOutput | Object | {"one": "a", "two": "b", "three": "c2", "four": "d", "five": "e"} |
451453
| arrayOutput | Array | ["one", "two", "three", "four"] |
452454

455+
The following example shows the deep merge capability:
456+
457+
```json
458+
{
459+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
460+
"contentVersion": "1.0.0.0",
461+
"parameters": {
462+
"firstObject": {
463+
"type": "object",
464+
"defaultValue": {
465+
"property": {
466+
"one": "a",
467+
"two": "b",
468+
"three": "c1"
469+
}
470+
}
471+
},
472+
"secondObject": {
473+
"type": "object",
474+
"defaultValue": {
475+
"property": {
476+
"three": "c2",
477+
"four": "d",
478+
"five": "e"
479+
}
480+
}
481+
},
482+
"firstArray": {
483+
"type": "array",
484+
"defaultValue": [
485+
[
486+
"one",
487+
"two"
488+
],
489+
[
490+
"three"
491+
]
492+
]
493+
},
494+
"secondArray": {
495+
"type": "array",
496+
"defaultValue": [
497+
[
498+
"three"
499+
],
500+
[
501+
"four",
502+
"two"
503+
]
504+
]
505+
}
506+
},
507+
"resources": [],
508+
"outputs": {
509+
"objectOutput": {
510+
"type": "object",
511+
"value": "[union(parameters('firstObject'), parameters('secondObject'))]"
512+
},
513+
"arrayOutput": {
514+
"type": "array",
515+
"value": "[union(parameters('firstArray'), parameters('secondArray'))]"
516+
}
517+
}
518+
}
519+
```
520+
521+
The output from the preceding example with the default values is:
522+
523+
| Name | Type | Value |
524+
| ---- | ---- | ----- |
525+
| objectOutput | Object |{"property":{"one":"a","two":"b","three":"c2","four":"d","five":"e"}}|
526+
| arrayOutput | Array |[["one","two"],["three"],["four","two"]]|
527+
453528
## Next steps
454529

455530
* 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)