@@ -9,32 +9,31 @@ title: array
99
1010## Synopsis
1111
12- Creates an array from the given elements (strings, numbers, arrays , or objects) .
12+ Wraps a single value (string, number, array , or object) in an array .
1313
1414## Syntax
1515
1616``` Syntax
17- array(<element1>, <element2>, ... )
17+ array(<value> )
1818```
1919
2020## Description
2121
22- The ` array() ` function creates an array from the provided arguments, allowing
23- mixed data types within the same array. Unlike ` createArray() ` which requires
24- all elements to be the same type, ` array() ` accepts any combination of strings,
25- numbers, arrays, and objects as arguments.
22+ The ` array() ` function returns a new array containing the single input value.
23+ The value can be a string, number, array, or object. Use
24+ ` createArray() ` to construct arrays with multiple elements of the same type.
2625
27- This function is useful when you need to combine different types of data into a
28- single collection, such as mixing configuration values, computed results, and
29- structured metadata in deployment scenarios .
26+ This function is useful when a schema expects an array, but you only have a
27+ single value, or when you need to nest an existing array or object inside an
28+ outer array .
3029
3130## Examples
3231
33- ### Example 1 - Build a deployment plan
32+ ### Example 1 - Wrap an existing array as a single element
3433
35- This example demonstrates combining different data types to create a comprehensive
36- deployment configuration. The array contains an existing server list, a numeric
37- batch size, and a configuration object with deployment strategy details .
34+ This example demonstrates wrapping an existing server list into a single array
35+ element, producing a nested array. This can be useful when a downstream schema
36+ expects an array of arrays .
3837
3938``` yaml
4039# array.example.1.dsc.config.yaml
@@ -52,7 +51,7 @@ resources:
5251- name : Deployment Plan
5352 type : Microsoft.DSC.Debug/Echo
5453 properties :
55- output : " [array(parameters('webServers'), parameters('batchSize'), createObject('strategy', 'blue-green') )]"
54+ output : " [array(parameters('webServers'))]"
5655` ` `
5756
5857` ` ` bash
@@ -68,17 +67,14 @@ results:
6867 output :
6968 - - web01
7069 - web02
71- - 2
72- - strategy : blue-green
7370messages : []
7471hadErrors : false
7572` ` `
7673
77- ### Example 2 - Compose mixed telemetry payload parts
74+ ### Example 2 - Wrap a single object for payloads
7875
79- This example shows how to construct a telemetry payload by combining a string
80- identifier, structured metadata object, and numeric status code into a single
81- array for logging or monitoring systems.
76+ This example shows how to wrap a structured metadata object into an array for
77+ logging or monitoring systems that expect arrays.
8278
8379` ` ` yaml
8480# array.example.2.dsc.config.yaml
@@ -92,7 +88,7 @@ resources:
9288 type : Microsoft.DSC.Debug/Echo
9389 properties :
9490 output :
95- payload : " [array(parameters('correlationId'), createObject('severity', 'info'), 200 )]"
91+ payload : " [array(createObject('severity', 'info'))]"
9692` ` `
9793
9894` ` ` bash
@@ -107,18 +103,15 @@ results:
107103 actualState :
108104 output :
109105 payload :
110- - ABC123
111106 - severity : info
112- - 200
113107messages : []
114108hadErrors : false
115109` ` `
116110
117- ### Example 3 - Combine generated and literal collections
111+ ### Example 3 - Wrap generated collections
118112
119- This example demonstrates nesting arrays and objects within a parent array,
120- showing how ` array()` can combine results from other DSC functions like
121- ` createArray()` and `createObject()` with literal values.
113+ This example demonstrates wrapping a generated collection (like one from
114+ ` createArray()` or `createObject()`) into an outer array.
122115
123116` ` ` yaml
124117# array.example.3.dsc.config.yaml
@@ -128,7 +121,8 @@ resources:
128121 type: Microsoft.DSC.Debug/Echo
129122 properties:
130123 output:
131- combined: "[array(createArray('a','b'), array(1,2), createObject('k','v'))]"
124+ combinedArray: "[array(createArray('a','b'))]"
125+ combinedObject: "[array(createObject('k','v'))]"
132126` ` `
133127
134128` ` ` bash
@@ -142,31 +136,31 @@ results:
142136 result:
143137 actualState:
144138 output:
145- combined :
139+ combinedArray :
146140 - - a
147141 - b
148- - - 1
149- - 2
142+ combinedObject:
150143 - k: v
151144messages: []
152145hadErrors: false
153146` ` `
154147
155148# # Parameters
156149
157- # ## element1, element2, ...
150+ # ## value
158151
159- The elements to include in the array.
152+ The single value to wrap in the array.
160153
161154` ` ` yaml
162155Type: string, number, array, or object
163156Required: false
164- Multiplicity: 0 or more
157+ MinimumCount: 1
158+ MaximumCount: 1
165159` ` `
166160
167- Each element provided as an argument will be added to the resulting array in the
168- order specified. All elements must be one of the four accepted types : string,
169- number (integer), array, or object. Boolean and null values are not supported.
161+ The provided value will be wrapped into the resulting array. The value must be
162+ one of the four accepted types : string, number (integer), array, or object.
163+ Boolean and null values are not supported.
170164
171165# # Output
172166
0 commit comments