Skip to content

Commit 1e0fd14

Browse files
authored
Merge branch 'main' into winget-manifest-uploader
2 parents 974289b + 961c94f commit 1e0fd14

File tree

13 files changed

+1356
-22
lines changed

13 files changed

+1356
-22
lines changed
Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
---
2+
description: Reference for the 'array' DSC configuration document function
3+
ms.date: 08/12/2025
4+
ms.topic: reference
5+
title: array
6+
---
7+
8+
# array
9+
10+
## Synopsis
11+
12+
Creates an array from the given elements (strings, numbers, arrays, or objects).
13+
14+
## Syntax
15+
16+
```Syntax
17+
array(<element1>, <element2>, ...)
18+
```
19+
20+
## Description
21+
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.
26+
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.
30+
31+
## Examples
32+
33+
### Example 1 - Build a deployment plan
34+
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.
38+
39+
```yaml
40+
# array.example.1.dsc.config.yaml
41+
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
42+
parameters:
43+
webServers:
44+
type: array
45+
defaultValue:
46+
- web01
47+
- web02
48+
batchSize:
49+
type: int
50+
defaultValue: 2
51+
resources:
52+
- name: Deployment Plan
53+
type: Microsoft.DSC.Debug/Echo
54+
properties:
55+
output: "[array(parameters('webServers'), parameters('batchSize'), createObject('strategy', 'blue-green'))]"
56+
```
57+
58+
```bash
59+
dsc config get --file array.example.1.dsc.config.yaml
60+
```
61+
62+
```yaml
63+
results:
64+
- name: Deployment Plan
65+
type: Microsoft.DSC.Debug/Echo
66+
result:
67+
actualState:
68+
output:
69+
- - web01
70+
- web02
71+
- 2
72+
- strategy: blue-green
73+
messages: []
74+
hadErrors: false
75+
```
76+
77+
### Example 2 - Compose mixed telemetry payload parts
78+
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.
82+
83+
```yaml
84+
# array.example.2.dsc.config.yaml
85+
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
86+
parameters:
87+
correlationId:
88+
type: string
89+
defaultValue: ABC123
90+
resources:
91+
- name: Telemetry Payload
92+
type: Microsoft.DSC.Debug/Echo
93+
properties:
94+
output:
95+
payload: "[array(parameters('correlationId'), createObject('severity', 'info'), 200)]"
96+
```
97+
98+
```bash
99+
dsc config get --file array.example.2.dsc.config.yaml
100+
```
101+
102+
```yaml
103+
results:
104+
- name: Telemetry Payload
105+
type: Microsoft.DSC.Debug/Echo
106+
result:
107+
actualState:
108+
output:
109+
payload:
110+
- ABC123
111+
- severity: info
112+
- 200
113+
messages: []
114+
hadErrors: false
115+
```
116+
117+
### Example 3 - Combine generated and literal collections
118+
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.
122+
123+
```yaml
124+
# array.example.3.dsc.config.yaml
125+
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
126+
resources:
127+
- name: Combined Collections
128+
type: Microsoft.DSC.Debug/Echo
129+
properties:
130+
output:
131+
combined: "[array(createArray('a','b'), array(1,2), createObject('k','v'))]"
132+
```
133+
134+
```bash
135+
dsc config get --file array.example.3.dsc.config.yaml
136+
```
137+
138+
```yaml
139+
results:
140+
- name: Combined Collections
141+
type: Microsoft.DSC.Debug/Echo
142+
result:
143+
actualState:
144+
output:
145+
combined:
146+
- - a
147+
- b
148+
- - 1
149+
- 2
150+
- k: v
151+
messages: []
152+
hadErrors: false
153+
```
154+
155+
## Parameters
156+
157+
### element1, element2, ...
158+
159+
The elements to include in the array.
160+
161+
```yaml
162+
Type: string, number, array, or object
163+
Required: false
164+
Multiplicity: 0 or more
165+
```
166+
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.
170+
171+
## Output
172+
173+
Returns a new array containing the provided elements in order.
174+
175+
```yaml
176+
Type: array
177+
```
178+
179+
## Related functions
180+
181+
- [`createArray()`][00] - Creates a homogeneous array (all elements same type)
182+
- [`createObject()`][01] - Builds an object from key/value pairs
183+
- [`first()`][02] - Gets the first element from an array
184+
- [`indexOf()`][03] - Finds the index of an item in an array
185+
186+
<!-- Link reference definitions -->
187+
[00]: ./createArray.md
188+
[01]: ./createObject.md
189+
[02]: ./first.md
190+
[03]: ./indexOf.md
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
---
2+
description: Reference for the 'endsWith' DSC configuration document function
3+
ms.date: 08/12/2025
4+
ms.topic: reference
5+
title: endsWith
6+
---
7+
8+
# endsWith
9+
10+
## Synopsis
11+
12+
Determines whether a string ends with the specified suffix.
13+
14+
## Syntax
15+
16+
```Syntax
17+
endsWith(<string>, <suffix>)
18+
```
19+
20+
## Description
21+
22+
The `endsWith()` function returns `true` if the first string ends with the
23+
specified suffix. Comparison is case-sensitive. Use it for conditional logic in
24+
configuration documents such as matching file extensions, environment name
25+
suffixes, or resource identifiers.
26+
27+
## Examples
28+
29+
### Example 1 - Check a file extension
30+
31+
The following example checks if a specified filename ends with `.log`.
32+
33+
```yaml
34+
# endswith.example.1.dsc.config.yaml
35+
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
36+
parameters:
37+
fileName:
38+
type: string
39+
defaultValue: application.log
40+
resources:
41+
- name: Check file extension
42+
type: Microsoft.DSC.Debug/Echo
43+
properties:
44+
output:
45+
isLog: "[endsWith(parameters('fileName'), '.log')]"
46+
```
47+
48+
```bash
49+
dsc config get --file endswith.example.1.dsc.config.yaml
50+
```
51+
52+
```yaml
53+
results:
54+
- name: Check file extension
55+
type: Microsoft.DSC.Debug/Echo
56+
result:
57+
actualState:
58+
output:
59+
isLog: true
60+
messages: []
61+
hadErrors: false
62+
```
63+
64+
### Example 2 - Conditional environment handling
65+
66+
The following example uses `endsWith()` to build a message when an environment
67+
name ends with `-prod`.
68+
69+
```yaml
70+
# endswith.example.2.dsc.config.yaml
71+
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
72+
parameters:
73+
environment:
74+
type: string
75+
defaultValue: web-prod
76+
resources:
77+
- name: Environment classification
78+
type: Microsoft.DSC.Debug/Echo
79+
properties:
80+
output:
81+
classification: "[if(endsWith(parameters('environment'), '-prod'), 'Production', 'Non-production')]"
82+
```
83+
84+
```bash
85+
dsc config get --file endswith.example.2.dsc.config.yaml
86+
```
87+
88+
```yaml
89+
results:
90+
- name: Environment classification
91+
type: Microsoft.DSC.Debug/Echo
92+
result:
93+
actualState:
94+
output:
95+
classification: Production
96+
messages: []
97+
hadErrors: false
98+
```
99+
100+
### Example 3 - Filter resource identifiers
101+
102+
The following example shows checking multiple suffixes by combining conditions.
103+
104+
```yaml
105+
# endswith.example.3.dsc.config.yaml
106+
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
107+
parameters:
108+
resourceId:
109+
type: string
110+
defaultValue: storage-westus-01
111+
resources:
112+
- name: Identify resource segment
113+
type: Microsoft.DSC.Debug/Echo
114+
properties:
115+
output:
116+
isRegional: "[endsWith(parameters('resourceId'), '-01')]"
117+
endsWithWest: "[endsWith(parameters('resourceId'), 'westus-01')]"
118+
endsWithEast: "[endsWith(parameters('resourceId'), 'eastus-01')]"
119+
```
120+
121+
```bash
122+
dsc config get --file endswith.example.3.dsc.config.yaml
123+
```
124+
125+
```yaml
126+
results:
127+
- name: Identify resource segment
128+
type: Microsoft.DSC.Debug/Echo
129+
result:
130+
actualState:
131+
output:
132+
isRegional: true
133+
endsWithWest: true
134+
endsWithEast: false
135+
messages: []
136+
hadErrors: false
137+
```
138+
139+
## Parameters
140+
141+
### string
142+
143+
The input string to evaluate.
144+
145+
```yaml
146+
Type: string
147+
Required: true
148+
Position: 1
149+
```
150+
151+
### suffix
152+
153+
The suffix string to test for.
154+
155+
```yaml
156+
Type: string
157+
Required: true
158+
Position: 2
159+
```
160+
161+
## Output
162+
163+
The `endsWith()` function returns a boolean value indicating whether the input
164+
string ends with the specified suffix.
165+
166+
```yaml
167+
Type: bool
168+
```
169+
170+
## Related functions
171+
172+
- [`startsWith()`][00] - Determines whether a string starts with a prefix
173+
- [`concat()`][01] - Concatenates strings together
174+
- [`if()`][02] - Returns values based on a condition
175+
- [`string()`][03] - Converts values to strings
176+
177+
<!-- Link reference definitions -->
178+
[00]: ./startsWith.md
179+
[01]: ./concat.md
180+
[02]: ./if.md
181+
[03]: ./string.md

0 commit comments

Comments
 (0)