Skip to content

Commit 9ebf140

Browse files
Merge pull request #303839 from MicrosoftDocs/main
Auto Publish – main to live - 2025-08-05 11:00 UTC
2 parents 921ee31 + 99b2f8f commit 9ebf140

File tree

41 files changed

+837
-362
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+837
-362
lines changed

articles/azure-resource-manager/templates/copy-resources.md

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Deploy multiple instances of resources
33
description: Use copy operation and arrays in an Azure Resource Manager template (ARM template) to deploy resource type many times.
44
ms.topic: how-to
55
ms.custom: devx-track-arm-template
6-
ms.date: 04/28/2025
6+
ms.date: 08/05/2025
77
---
88

99
# Resource iteration in ARM templates
@@ -12,10 +12,10 @@ This article shows you how to create more than one instance of a resource in you
1212

1313
You can also use copy loop with [properties](copy-properties.md), [variables](copy-variables.md), and [outputs](copy-outputs.md).
1414

15-
If you need to specify whether a resource is deployed at all, see [condition element](conditional-resource-deployment.md).
15+
If you need to specify if a resource is deployed at all, see the [condition](conditional-resource-deployment.md) element.
1616

1717
> [!TIP]
18-
> We recommend [Bicep](../bicep/overview.md) because it offers the same capabilities as ARM templates and the syntax is easier to use. To learn more, see [loops](../bicep/loops.md).
18+
> [Bicep](../bicep/overview.md) is recommended since it offers the same capabilities as ARM templates, and the syntax is easier to use. To learn more, see [loops](../bicep/loops.md).
1919
2020
## Syntax
2121

@@ -32,26 +32,24 @@ Add the `copy` element to the resources section of your template to deploy multi
3232

3333
The `name` property is any value that identifies the loop. The `count` property specifies the number of iterations you want for the resource type.
3434

35-
Use the `mode` and `batchSize` properties to specify if the resources are deployed in parallel or in sequence. These properties are described in [Serial or Parallel](#serial-or-parallel).
35+
Use the `mode` and `batchSize` properties to specify if the resources are deployed in parallel or in sequence. These properties are described in [serial or parallel](#serial-or-parallel).
3636

3737
## Copy limits
3838

39-
The count can't exceed 800.
39+
The count can't exceed 800 or be a negative number. It can be zero if you deploy the template with a recent version of the Azure CLI, PowerShell, or REST API. Specifically, you must use:
4040

41-
The count can't be a negative number. It can be zero if you deploy the template with a recent version of Azure CLI, PowerShell, or REST API. Specifically, you must use:
41+
- Azure PowerShell **2.6** or later.
42+
- Azure CLI **2.0.74** or later.
43+
- REST API version **2019-05-10** or later.
44+
- API version **2019-05-10** or later for the deployment resource type during [linked deployments](linked-templates.md).
4245

43-
- Azure PowerShell **2.6** or later
44-
- Azure CLI **2.0.74** or later
45-
- REST API version **2019-05-10** or later
46-
- [Linked deployments](linked-templates.md) must use API version **2019-05-10** or later for the deployment resource type
46+
Earlier versions of PowerShell, CLI, and the REST API don't support zero for the count.
4747

48-
Earlier versions of PowerShell, CLI, and the REST API don't support zero for count.
49-
50-
Be careful using [complete mode deployment](deployment-modes.md) with copy loop. If you redeploy with complete mode to a resource group, any resources that aren't specified in the template after resolving the copy loop are deleted.
48+
Be careful using [complete mode deployment](deployment-modes.md) with the copy loop. If you redeploy with complete mode to a resource group, any resources that aren't specified in the template after resolving the copy loop are deleted.
5149

5250
## Resource iteration
5351

54-
The following example creates the number of storage accounts specified in the `storageCount` parameter.
52+
The following example creates the number of storage accounts specified in the `storageCount` parameter:
5553

5654
```json
5755
{
@@ -113,7 +111,7 @@ Creates these names:
113111

114112
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.
115113

116-
The following example creates one storage account for each name provided in the parameter.
114+
The following example creates one storage account for each name provided in the parameter:
117115

118116
```json
119117
{
@@ -153,11 +151,11 @@ The following example creates one storage account for each name provided in the
153151
}
154152
```
155153

156-
If you want to return values from the deployed resources, you can use [copy in the outputs section](copy-outputs.md).
154+
If you want to return values from the deployed resources, you can [use copy in the **outputs** section](copy-outputs.md).
157155

158156
### Use symbolic name
159157

160-
[Symbolic name](./resource-declaration.md#use-symbolic-name) will be assigned to resource copy loops. The loop index is zero-based. In the following example, `myStorages[1]` references the second resource in the resource loop.
158+
[Symbolic name](./resource-declaration.md#use-symbolic-name) will be assigned to resource copy loops. The loop index is zero-based. In the following example, `myStorages[1]` references the second resource in the resource loop:
161159

162160
```json
163161
{
@@ -200,7 +198,7 @@ If you want to return values from the deployed resources, you can use [copy in t
200198
}
201199
```
202200

203-
If the index is a runtime value, format the reference yourself. For example
201+
If the index is a runtime value, format the reference yourself. For example:
204202

205203
```json
206204
"outputs": {
@@ -211,17 +209,17 @@ If the index is a runtime value, format the reference yourself. For example
211209
}
212210
```
213211

214-
Symbolic names can be used in [dependsOn arrays](./resource-dependency.md#depend-on-resources-in-a-loop). If a symbolic name is for a copy loop, all resources in the loop are added as dependencies. For more information, see [Depends on resources in a loop](./resource-dependency.md#depend-on-resources-in-a-loop).
212+
Symbolic names can be used in [dependsOn arrays](./resource-dependency.md#depend-on-resources-in-a-loop). If a symbolic name is for a copy loop, all resources in the loop are added as dependencies. For more information, see [depends-on resources in a loop](./resource-dependency.md#depend-on-resources-in-a-loop).
215213

216-
## Serial or Parallel
214+
## Serial or parallel
217215

218-
By default, Resource Manager creates the resources in parallel. It applies no limit to the number of resources deployed in parallel, other than the total limit of 800 resources in the template. The order in which they're created isn't guaranteed.
216+
By default, Resource Manager creates the resources in parallel. It applies no limit to the number of resources deployed in parallel other than the total limit of 800 resources in the template. The order in which they're created isn't guaranteed.
219217

220-
However, you may want to specify that the resources are deployed in sequence. For example, when updating a production environment, you may want to stagger the updates so only a certain number are updated at any one time.
218+
However, you might want to specify that the resources are deployed in sequence. For example, when updating a production environment, you can stagger the updates so that only a certain number update at any one time.
221219

222-
To serially deploy more than one instance of a resource, set `mode` to **serial** and `batchSize` to the number of instances to deploy at a time. With serial mode, Resource Manager creates a dependency on earlier instances in the loop, so it doesn't start one batch until the previous batch completes.
220+
To serially deploy more than one instance of a resource, set `mode` to **serial** and `batchSize` to the number of instances to deploy at a time. With serial mode, Resource Manager creates a dependency on earlier instances in the loop so that it doesn't start one batch until the previous batch completes.
223221

224-
The value for `batchSize` can't exceed the value for `count` in the copy element.
222+
The value for `batchSize` can't exceed the value for `count` in the copy element:
225223

226224
```json
227225
{
@@ -261,7 +259,7 @@ The `mode` property also accepts **parallel**, which is the default value.
261259

262260
You can't use a copy loop for a child resource. To create more than one instance of a resource that you typically define as nested within another resource, you must instead create that resource as a top-level resource. You define the relationship with the parent resource through the type and name properties.
263261

264-
For example, suppose you typically define a dataset as a child resource within a data factory.
262+
For example, suppose you typically define a dataset as a child resource within a data factory:
265263

266264
```json
267265
{
@@ -286,11 +284,11 @@ For example, suppose you typically define a dataset as a child resource within a
286284
}
287285
```
288286

289-
To create more than one data set, move it outside of the data factory. The dataset must be at the same level as the data factory, but it's still a child resource of the data factory. You preserve the relationship between data set and data factory through the type and name properties. Since type can no longer be inferred from its position in the template, you must provide the fully qualified type in the format: `{resource-provider-namespace}/{parent-resource-type}/{child-resource-type}`.
287+
To create more than one dataset, move it outside of the data factory. The dataset must be at the same level as the data factory, but it's still a child resource of the data factory. The type and name properties preserve the relationship between the dataset and data factory. Since type can no longer be inferred from its position in the template, you must provide the fully qualified type in this format: `{resource-provider-namespace}/{parent-resource-type}/{child-resource-type}`.
290288

291-
To establish a parent/child relationship with an instance of the data factory, provide a name for the data set that includes the parent resource name. Use the format: `{parent-resource-name}/{child-resource-name}`.
289+
To establish a parent/child relationship with an instance of the data factory, provide a name for the dataset that includes the parent resource name. Use this format: `{parent-resource-name}/{child-resource-name}`.
292290

293-
The following example shows the implementation.
291+
The following example shows the implementation:
294292

295293
```json
296294
"resources": [
@@ -326,11 +324,11 @@ The following examples show common scenarios for creating more than one instance
326324

327325
## Next steps
328326

329-
- To set dependencies on resources that are created in a copy loop, see [Define the order for deploying resources in ARM templates](./resource-dependency.md).
330-
- To go through a tutorial, see [Tutorial: Create multiple resource instances with ARM templates](template-tutorial-create-multiple-instances.md).
331-
- For a Learn module that covers resource copy, see [Manage complex cloud deployments by using advanced ARM template features](/training/modules/manage-deployments-advanced-arm-template-features/).
327+
- To set dependencies on resources that are created in a copy loop, see how to [define the order for deploying resources in ARM templates](./resource-dependency.md).
328+
- To go through a tutorial, see one for how to [create multiple resource instances with ARM templates](template-tutorial-create-multiple-instances.md).
329+
- For a Microsoft Learn module that covers resource copy, see how to [manage complex cloud deployments by using advanced ARM template features](/training/modules/manage-deployments-advanced-arm-template-features/).
332330
- For other uses of the copy loop, see:
333331
- [Property iteration in ARM templates](copy-properties.md)
334332
- [Variable iteration in ARM templates](copy-variables.md)
335333
- [Output iteration in ARM templates](copy-outputs.md)
336-
- For information about using copy with nested templates, see [Using copy](linked-templates.md#using-copy).
334+
- For information about using copy with nested templates, see how to [use copy](linked-templates.md#use-copy).

0 commit comments

Comments
 (0)