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/template-tutorial-add-parameters.md
+23-23Lines changed: 23 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,33 +2,33 @@
2
2
title: Tutorial - add parameters to template
3
3
description: Add parameters to your Azure Resource Manager template (ARM template) to make it reusable.
4
4
author: mumian
5
-
ms.date: 03/31/2020
5
+
ms.date: 06/15/2022
6
6
ms.topic: tutorial
7
7
ms.author: jgao
8
8
ms.custom: devx-track-azurepowershell
9
9
---
10
10
11
11
# Tutorial: Add parameters to your ARM template
12
12
13
-
In the [previous tutorial](template-tutorial-add-resource.md), you learned how to add a storage account to the template and deploy it. In this tutorial, you learn how to improve the Azure Resource Manager template (ARM template) by adding parameters. This tutorial takes about **14 minutes** to complete.
13
+
In the [previous tutorial](template-tutorial-add-resource.md), you learned how to add an [Azure storage account](../../storage/common/storage-account-create.md) to the template and deploy it. In this tutorial, you learn how to improve the Azure Resource Manager template (ARM template) by adding parameters. This tutorial takes about **14 minutes** to complete.
14
14
15
15
## Prerequisites
16
16
17
17
We recommend that you complete the [tutorial about resources](template-tutorial-add-resource.md), but it's not required.
18
18
19
-
You must have Visual Studio Codewith the Resource Manager Tools extension, and either Azure PowerShell or Azure CLI. For more information, see [template tools](template-tutorial-create-first-template.md#get-tools).
19
+
You need to have [Visual Studio Code](https://code.visualstudio.com/) installed and working with the Azure Resource Manager Tools extension, and either Azure PowerShell or Azure CLI. For more information, see [template tools](template-tutorial-create-first-template.md#get-tools).
20
20
21
21
## Review template
22
22
23
-
At the end of the previous tutorial, your template had the following JSON:
23
+
At the end of the previous tutorial, your template has the following JSON file:
You may have noticed that there's a problem with this template. The storage account name is hard-coded. You can only use this template to deploy the same storage account every time. To deploy a storage account with a different name, you would have to create a new template, which obviously isn't a practical way to automate your deployments.
27
+
You may notice that there's a problem with this template. The storage account name is hard-coded. You can only use this template to deploy the same storage account every time. To deploy a storage account with a different name, you need to create a new template, which obviously isn't a practical way to automate your deployments.
28
28
29
29
## Make template reusable
30
30
31
-
To make your template reusable, let's add a parameter that you can use to pass in a storage account name. The highlighted JSON in the following example shows what changed in your template. The `storageName` parameter is identified as a string. The maximum length is set to 24 characters to prevent any names that are too long.
31
+
To make your template reusable, let's add a parameter that you can use to pass in a storage account name. The highlighted JSON file in the following example shows the changes in your template. The `storageName` parameter is identified as a string. The storage account name is all lowercase letters or numbers and has a limit of 24 characters.
32
32
33
33
Copy the whole file and replace your template with its contents.
34
34
@@ -38,7 +38,7 @@ Copy the whole file and replace your template with its contents.
38
38
39
39
Let's deploy the template. The following example deploys the template with Azure CLI or PowerShell. Notice that you provide the storage account name as one of the values in the deployment command. For the storage account name, provide the same name you used in the previous tutorial.
40
40
41
-
If you haven't created the resource group, see [Create resource group](template-tutorial-create-first-template.md#create-resource-group). The example assumes you've set the `templateFile` variable to the path to the template file, as shown in the [first tutorial](template-tutorial-create-first-template.md#deploy-template).
41
+
If you haven't created the resource group, see [Create resource group](template-tutorial-create-first-template.md#create-resource-group). The example assumes you set the `templateFile` variable to the path of the template file, as shown in the [first tutorial](template-tutorial-create-first-template.md#deploy-template).
42
42
43
43
# [PowerShell](#tab/azure-powershell)
44
44
@@ -52,7 +52,7 @@ New-AzResourceGroupDeployment `
52
52
53
53
# [Azure CLI](#tab/azure-cli)
54
54
55
-
To run this deployment command, you must have the [latest version](/cli/azure/install-azure-cli) of Azure CLI.
55
+
To run this deployment command, you need to have the [latest version](/cli/azure/install-azure-cli) of Azure CLI.
56
56
57
57
```azurecli
58
58
az deployment group create \
@@ -66,25 +66,25 @@ az deployment group create \
66
66
67
67
## Understand resource updates
68
68
69
-
In the previous section, you deployed a storage account with the same name that you had created earlier. You may be wondering how the resource is affected by the redeployment.
69
+
After you deploy a storage account with the same name you used earlier, you may wonder how the redeployment affects the resource.
70
70
71
-
If the resource already exists and no change is detected in the properties, no action is taken. If the resource already exists and a property has changed, the resource is updated. If the resource doesn't exist, it's created.
71
+
If the resource already exists, and there's no change in the properties, there's no need for further action. If the resource exists and a property changes, it updates. If the resource doesn't exist, it's created.
72
72
73
-
This way of handling updates means your template can include all of the resources you need for an Azure solution. You can safely redeploy the template and know that resources are changed or created only when needed. For example, if you have added files to your storage account, you can redeploy the storage account without losing those files.
73
+
This way of handling updates means your template can include all of the resources you need for an Azure solution. You can safely redeploy the template and know that resources change or are created only when needed. If you add files to your storage account, for example, you can redeploy the storage account without losing the files.
74
74
75
75
## Customize by environment
76
76
77
-
Parameters enable you to customize the deployment by providing values that are tailored for a particular environment. For example, you can pass different valuesbased on whether you're deploying to an environment for development, test, and production.
77
+
Parameters let you customize the deployment by providing values that tailored for a particular environment. You can pass different values, for example, based on whether you're deploying to a development, testing, or production environment.
78
78
79
-
The previous template always deployed a **Standard_LRS**storage account. You might want the flexibility to deploy different SKUs depending on the environment. The following example shows the changes to add a parameter for SKU. Copy the whole file and paste over your template.
79
+
The previous template always deploys a standard locally redundant storage (LRS) **Standard_LRS** account. You might want the flexibility to deploy different stock keeping units (SKUs) depending on the environment. The following example shows the changes to add a parameter for SKU. Copy the whole file and paste it over your template.
The `storageSKU` parameter has a default value. This value is used when a value isn't specified during the deployment. It also has a list of allowed values. These values match the values that are needed to create a storage account. You don't want users of your template to pass in SKUs that don't work.
83
+
The `storageSKU` parameter has a default value. Use this value when the deployment doesn't specify it. It also has a list of allowed values. These values match the values that are needed to create a storage account. You want your template users to pass SKUs that work.
84
84
85
85
## Redeploy template
86
86
87
-
You're ready to deploy again. Because the default SKU is set to **Standard_LRS**, you don't need to provide a value for that parameter.
87
+
You're ready to deploy again. Because the default SKU is set to **Standard_LRS**, you've already provided a parameter value.
88
88
89
89
# [PowerShell](#tab/azure-powershell)
90
90
@@ -109,9 +109,9 @@ az deployment group create \
109
109
---
110
110
111
111
> [!NOTE]
112
-
> If the deployment failed, use the `verbose` switch to get information about the resources being created. Use the `debug` switch to get more information for debugging.
112
+
> If the deployment fails, use the `verbose` switch to get information about the resources being created. Use the `debug` switch to get more information for debugging.
113
113
114
-
To see the flexibility of your template, let's deploy again. This time set the SKU parameter to **Standard_GRS**. You can either pass in a new name to create a different storage account, or use the same name to update your existing storage account. Both options work.
114
+
To see the flexibility of your template, let's deploy it again. This time set the SKU parameter to standard geo-redundant storage (GRS) **Standard_GRS**. You can either pass in a new name to create a different storage account or use the same name to update your existing storage account. Both options work.
115
115
116
116
# [PowerShell](#tab/azure-powershell)
117
117
@@ -136,7 +136,7 @@ az deployment group create \
136
136
137
137
---
138
138
139
-
Finally, let's run one more test and see what happens when you pass in a SKU that isn't one of the allowed values. In this case, we test the scenario where a user of your template thinks **basic** is one of the SKUs.
139
+
Finally, let's run one more test and see what happens when you pass in an SKU that isn't one of the allowed values. In this case, we test the scenario where your template user thinks **basic** is one of the SKUs.
140
140
141
141
# [PowerShell](#tab/azure-powershell)
142
142
@@ -161,22 +161,22 @@ az deployment group create \
161
161
162
162
---
163
163
164
-
The command fails immediately with an error message that states which values are allowed. Resource Manager identifies the error before the deployment starts.
164
+
The command fails at once with an error message that gives the allowed values. The ARM processor finds the error before the deployment starts.
165
165
166
166
## Clean up resources
167
167
168
168
If you're moving on to the next tutorial, you don't need to delete the resource group.
169
169
170
-
If you're stopping now, you might want to clean up the resources you deployed by deleting the resource group.
170
+
If you're stopping now, you might want to clean up your deployed resources by deleting the resource group.
171
171
172
172
1. From the Azure portal, select **Resource group** from the left menu.
173
-
2.Enter the resource group name in the **Filter by name** field.
174
-
3.Select the resource group name.
173
+
2.Type the resource group name in the **Filter for any field ...** text field.
174
+
3.Check the box next to myResourceGroup and select **myResourceGroup** or your resource group name.
175
175
4. Select **Delete resource group** from the top menu.
176
176
177
177
## Next steps
178
178
179
-
You improved the template created in the [first tutorial](template-tutorial-create-first-template.md) by adding parameters. In the next tutorial, you'll learn about template functions.
179
+
You improved the template you created in the [first tutorial](template-tutorial-create-first-template.md) by adding parameters. In the next tutorial, you learn about template functions.
0 commit comments