Skip to content

Commit a86b7ea

Browse files
authored
Merge pull request #212885 from mumian/0928-multi-instances
Refresh the multi-instance tutorial
2 parents 75bd5dc + dac4ab7 commit a86b7ea

File tree

2 files changed

+35
-13
lines changed

2 files changed

+35
-13
lines changed
Loading

articles/azure-resource-manager/templates/template-tutorial-create-multiple-instances.md

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Create multiple resource instances
33
description: Learn how to create an Azure Resource Manager template (ARM template) to create multiple Azure resource instances.
44
author: mumian
5-
ms.date: 04/23/2020
5+
ms.date: 09/28/2022
66
ms.topic: tutorial
77
ms.author: jgao
88
ms.custom: devx-track-azurepowershell
@@ -43,7 +43,7 @@ To complete this article, you need:
4343
```
4444

4545
1. Select **Open** to open the file.
46-
1. There is a `Microsoft.Storage/storageAccounts` resource defined in the template. Compare the template to the [template reference](/azure/templates/Microsoft.Storage/storageAccounts). It's helpful to get some basic understanding of the template before customizing it.
46+
1. There's a `Microsoft.Storage/storageAccounts` resource defined in the template. Compare the template to the [template reference](/azure/templates/Microsoft.Storage/storageAccounts). It's helpful to get some basic understanding of the template before customizing it.
4747
1. Select **File** > **Save As** to save the file as _azuredeploy.json_ to your local computer.
4848

4949
## Edit the template
@@ -55,9 +55,25 @@ From Visual Studio Code, make the following four changes:
5555
![Azure Resource Manager creates multiple instances](./media/template-tutorial-create-multiple-instances/resource-manager-template-create-multiple-instances.png)
5656

5757
1. Add a `copy` element to the storage account resource definition. In the `copy` element, you specify the number of iterations and a variable for this loop. The count value must be a positive integer and can't exceed 800.
58-
2. The `copyIndex()` function returns the current iteration in the loop. You use the index as the name prefix. `copyIndex()` is zero-based. To offset the index value, you can pass a value in the `copyIndex()` function. For example, `copyIndex(1)`.
59-
3. Delete the `variables` element, because it's not used anymore.
60-
4. Delete the `outputs` element. It's no longer needed.
58+
59+
```json
60+
"copy": {
61+
"name": "storageCopy",
62+
"count": 3
63+
},
64+
```
65+
66+
1. The `copyIndex()` function returns the current iteration in the loop. You use the index as the name prefix. `copyIndex()` is zero-based. To offset the index value, you can pass a value in the `copyIndex()` function. For example, `copyIndex(1)`.
67+
68+
```json
69+
"name": "[format('{0}storage{1}', copyIndex(), uniqueString(resourceGroup().id))]",
70+
```
71+
72+
```
73+
74+
1. Delete the `storageAccountName` parameter definition, because it's not used anymore.
75+
1. Delete the `outputs` element. It's no longer needed.
76+
1. Delete the `metadata` element.
6177
6278
The completed template looks like:
6379
@@ -70,10 +86,14 @@ The completed template looks like:
7086
"type": "string",
7187
"defaultValue": "Standard_LRS",
7288
"allowedValues": [
73-
"Standard_LRS",
89+
"Premium_LRS",
90+
"Premium_ZRS",
7491
"Standard_GRS",
75-
"Standard_ZRS",
76-
"Premium_LRS"
92+
"Standard_GZRS",
93+
"Standard_LRS",
94+
"Standard_RAGRS",
95+
"Standard_RAGZRS",
96+
"Standard_ZRS"
7797
],
7898
"metadata": {
7999
"description": "Storage Account type"
@@ -83,22 +103,22 @@ The completed template looks like:
83103
"type": "string",
84104
"defaultValue": "[resourceGroup().location]",
85105
"metadata": {
86-
"description": "Location for all resources."
106+
"description": "Location for the storage account."
87107
}
88108
}
89109
},
90110
"resources": [
91111
{
92112
"type": "Microsoft.Storage/storageAccounts",
93-
"apiVersion": "2019-04-01",
94-
"name": "[concat(copyIndex(),'storage', uniqueString(resourceGroup().id))]",
113+
"apiVersion": "2021-06-01",
114+
"name": "[format('{0}storage{1}', copyIndex(), uniqueString(resourceGroup().id))]",
95115
"location": "[parameters('location')]",
96116
"sku": {
97117
"name": "[parameters('storageAccountType')]"
98118
},
99119
"kind": "StorageV2",
100120
"copy": {
101-
"name": "storagecopy",
121+
"name": "storageCopy",
102122
"count": 3
103123
},
104124
"properties": {}
@@ -107,6 +127,8 @@ The completed template looks like:
107127
}
108128
```
109129
130+
Save the changes.
131+
110132
For more information about creating multiple instances, see [Resource iteration in ARM templates](./copy-resources.md)
111133
112134
## Deploy the template
@@ -146,7 +168,7 @@ For more information about creating multiple instances, see [Resource iteration
146168
147169
---
148170
149-
After a successful template deployment you can display the three storage accounts created in the specified resource group. Compare the storage account names with the name definition in the template.
171+
After a successful template deployment, you can display the three storage accounts created in the specified resource group. Compare the storage account names with the name definition in the template.
150172
151173
# [CLI](#tab/azure-cli)
152174

0 commit comments

Comments
 (0)