|
2 | 2 | title: Deploy multiple instances of Azure resources | Microsoft Docs
|
3 | 3 | description: Use copy operation and arrays in an Azure Resource Manager template to iterate multiple times when deploying resources.
|
4 | 4 | services: azure-resource-manager
|
5 |
| -documentationcenter: na |
6 | 5 | author: tfitzmac
|
7 |
| -editor: '' |
8 |
| - |
9 | 6 | ms.service: azure-resource-manager
|
10 |
| -ms.devlang: na |
11 | 7 | ms.topic: conceptual
|
12 |
| -ms.tgt_pltfrm: na |
13 |
| -ms.workload: na |
14 |
| -ms.date: 05/01/2019 |
| 8 | +ms.date: 06/06/2019 |
15 | 9 | ms.author: tomfitz
|
16 | 10 |
|
17 | 11 | ---
|
18 |
| -# Deploy more than one instance of a resource or property in Azure Resource Manager Templates |
| 12 | +# Resource, property, or variable iteration in Azure Resource Manager templates |
| 13 | + |
| 14 | +This article shows you how to create more than one instance of a resource, variable, or property in your Azure Resource Manager template. To create multiple instances, add the `copy` object to your template. |
| 15 | + |
| 16 | +When used with a resource, the copy object has the following format: |
| 17 | + |
| 18 | +```json |
| 19 | +"copy": { |
| 20 | + "name": "<name-of-loop>", |
| 21 | + "count": <number-of-iterations>, |
| 22 | + "mode": "serial" <or> "parallel", |
| 23 | + "batchSize": <number-to-deploy-serially> |
| 24 | +} |
| 25 | +``` |
| 26 | + |
| 27 | +When used with a variable or property, the copy object has the following format: |
| 28 | + |
| 29 | +```json |
| 30 | +"copy": [ |
| 31 | + { |
| 32 | + "name": "<name-of-loop>", |
| 33 | + "count": <number-of-iterations>, |
| 34 | + "input": <values-for-the-property-or-variable> |
| 35 | + } |
| 36 | +] |
| 37 | +``` |
| 38 | + |
| 39 | +Both uses are described in greater detail in this article. For a tutorial, see [Tutorial: create multiple resource instances using Resource Manager templates](./resource-manager-tutorial-create-multiple-instances.md). |
| 40 | + |
| 41 | +If you need to specify whether a resource is deployed at all, see [condition element](resource-group-authoring-templates.md#condition). |
19 | 42 |
|
20 |
| -This article shows you how to iterate in your Azure Resource Manager template to create more than one instance of a resource. If you need to specify whether a resource is deployed at all, see [condition element](resource-group-authoring-templates.md#condition). |
| 43 | +## Copy limits |
21 | 44 |
|
22 |
| -For a tutorial, see [Tutorial: create multiple resource instances using Resource Manager templates](./resource-manager-tutorial-create-multiple-instances.md). |
| 45 | +To specify the number of iterations, you provide a value for the count property. The count can't exceed 800. |
23 | 46 |
|
| 47 | +The count can't be a negative number. If you deploy a template with REST API version **2019-05-10** or later, you can set count to zero. Earlier versions of the REST API don't support zero for count. Currently, Azure CLI or PowerShell don't support zero for count, but that support will be added in a future release. |
24 | 48 |
|
25 |
| -[!INCLUDE [updated-for-az](../../includes/updated-for-az.md)] |
| 49 | +The limits for the count are the same whether used with a resource, variable, or property. |
26 | 50 |
|
27 | 51 | ## Resource iteration
|
28 | 52 |
|
29 |
| -When you must decide during deployment to create one or more instances of a resource, add a `copy` element to the resource type. In the copy element, you specify the number of iterations and a name for this loop. The count value must be a positive integer and can't be more than 800. |
| 53 | +When you must decide during deployment to create one or more instances of a resource, add a `copy` element to the resource type. In the copy element, specify the number of iterations and a name for this loop. |
30 | 54 |
|
31 | 55 | The resource to create several times takes the following format:
|
32 | 56 |
|
@@ -67,7 +91,7 @@ Creates these names:
|
67 | 91 | * storage1
|
68 | 92 | * storage2.
|
69 | 93 |
|
70 |
| -To offset the index value, you can pass a value in the copyIndex() function. The number of iterations to perform is still specified in the copy element, but the value of copyIndex is offset by the specified value. So, the following example: |
| 94 | +To offset the index value, you can pass a value in the copyIndex() function. The number of iterations is still specified in the copy element, but the value of copyIndex is offset by the specified value. So, the following example: |
71 | 95 |
|
72 | 96 | ```json
|
73 | 97 | "name": "[concat('storage', copyIndex(1))]",
|
@@ -152,7 +176,7 @@ For information about using copy with nested templates, see [Using copy](resourc
|
152 | 176 | To create more than one value for a property on a resource, add a `copy` array in the properties element. This array contains objects, and each object has the following properties:
|
153 | 177 |
|
154 | 178 | * name - the name of the property to create several values for
|
155 |
| -* count - the number of values to create. The count value must be a positive integer and can't be more than 800. |
| 179 | +* count - the number of values to create. |
156 | 180 | * input - an object that contains the values to assign to the property
|
157 | 181 |
|
158 | 182 | The following example shows how to apply `copy` to the dataDisks property on a virtual machine:
|
|
0 commit comments