@@ -50,6 +50,7 @@ resources:
5050 properties :
5151 output : " Hello DSC"
5252` ` `
53+
5354` ` ` bash
5455dsc config get --file copyIndex.example.1.dsc.config.yaml
5556```
@@ -74,9 +75,12 @@ results:
7475messages : []
7576hadErrors : false
7677` ` `
78+
7779### Example 2 - Using copyIndex with offset
80+
7881This example demonstrates using an offset to start numbering from a different
7982value.
83+
8084` ` ` yaml
8185# copyIndex.example.2.dsc.config.yaml
8286$schema : https://aka.ms/dsc/schemas/v3/bundled/config/document.json
@@ -89,6 +93,7 @@ resources:
8993 properties :
9094 output : " Server instance starting from 10 till 12"
9195` ` `
96+
9297` ` ` bash
9398dsc config get --file copyIndex.example.2.dsc.config.yaml
9499```
@@ -113,8 +118,11 @@ results:
113118messages : []
114119hadErrors : false
115120` ` `
121+
116122### Example 3 - Using copyIndex with loop name
123+
117124This example shows how to reference a specific loop by name.
125+
118126` ` ` yaml
119127# copyIndex.example.3.dsc.config.yaml
120128$schema : https://aka.ms/dsc/schemas/v3/bundled/config/document.json
@@ -127,6 +135,7 @@ resources:
127135 properties :
128136 output : " Item from loop"
129137` ` `
138+
130139` ` ` bash
131140dsc config get --file copyIndex.example.3.dsc.config.yaml
132141```
@@ -141,8 +150,11 @@ results:
141150messages : []
142151hadErrors : false
143152` ` `
153+
144154### Example 4 - Using copyIndex with loop name and offset
155+
145156This example combines both loop name and offset parameters.
157+
146158` ` ` yaml
147159# copyIndex.example.4.dsc.config.yaml
148160$schema : https://aka.ms/dsc/schemas/v3/bundled/config/document.json
@@ -155,6 +167,7 @@ resources:
155167 properties :
156168 output : " Database instance"
157169` ` `
170+
158171` ` ` bash
159172dsc config get --file copyIndex.example.4.dsc.config.yaml
160173```
@@ -174,23 +187,32 @@ results:
174187messages : []
175188hadErrors : false
176189` ` `
190+
177191## Parameters
192+
178193### offset
194+
179195An optional integer offset to add to the current index. The offset must be a
180196non-negative number.
197+
181198` ` ` yaml
182199Type : integer
183200Required : false
184201Minimum : 0
185202` ` `
203+
186204### loopName
205+
187206An optional string specifying the name of the copy loop to reference. This is
188207useful when you have multiple copy loops and need to reference a specific one.
208+
189209` ` ` yaml
190210Type : string
191211Required : false
192212` ` `
213+
193214## Output
215+
194216The ` copyIndex()` function returns an integer representing the current iteration
195217index, optionally adjusted by the offset.
196218
@@ -215,4 +237,4 @@ The `copyIndex()` function will return an error in the following situations:
215237- [`copy`][01] - Defines a loop to create multiple instances of a resource.
216238
217239<!-- Link reference definitions -->
218- [01] : ./copy.md
240+ [01] : ./copy.md
0 commit comments