You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-resource-manager/templates/copy-properties.md
+65-7Lines changed: 65 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
title: Define multiple instances of a property
3
3
description: Use copy operation in an Azure Resource Manager template to iterate multiple times when creating a property on a resource.
4
4
ms.topic: conceptual
5
-
ms.date: 02/13/2020
5
+
ms.date: 04/14/2020
6
6
---
7
7
# Property iteration in ARM templates
8
8
@@ -24,7 +24,9 @@ The copy element has the following general format:
24
24
]
25
25
```
26
26
27
-
For **name**, provide the name of the resource property that you want to create. The **count** property specifies the number of iterations you want for the property.
27
+
For **name**, provide the name of the resource property that you want to create.
28
+
29
+
The **count** property specifies the number of iterations you want for the property.
28
30
29
31
The **input** property specifies the properties that you want to repeat. You create an array of elements constructed from the value in the **input** property.
30
32
@@ -72,11 +74,7 @@ The following example shows how to apply `copy` to the dataDisks property on a v
72
74
}
73
75
```
74
76
75
-
Notice that when using `copyIndex` inside a property iteration, you must provide the name of the iteration.
76
-
77
-
> [!NOTE]
78
-
> Property iteration also supports an offset argument. The offset must come after the name of the iteration, such as copyIndex('dataDisks', 1).
79
-
>
77
+
Notice that when using `copyIndex` inside a property iteration, you must provide the name of the iteration. Property iteration also supports an offset argument. The offset must come after the name of the iteration, such as copyIndex('dataDisks', 1).
80
78
81
79
Resource Manager expands the `copy` array during deployment. The name of the array becomes the name of the property. The input values become the object properties. The deployed template becomes:
82
80
@@ -107,6 +105,66 @@ Resource Manager expands the `copy` array during deployment. The name of the arr
107
105
...
108
106
```
109
107
108
+
The copy operation is helpful when working with arrays because you can iterate through each element in the array. Use the `length` function on the array to specify the count for iterations, and `copyIndex` to retrieve the current index in the array.
109
+
110
+
The following example template creates a failover group for databases that are passed in as an array.
0 commit comments