Skip to content

Commit 5d45029

Browse files
authored
Merge pull request #86085 from tfitzmac/0820params
added parameter file
2 parents 14cc273 + 7ee2a2e commit 5d45029

File tree

2 files changed

+211
-3
lines changed

2 files changed

+211
-3
lines changed
Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
---
2+
title: Create Azure Resource Manager parameter file
3+
description: Create parameter file for passing in values during deployment of an Azure Resource Manager template
4+
author: tfitzmac
5+
ms.service: azure-resource-manager
6+
ms.topic: conceptual
7+
ms.date: 08/21/2019
8+
ms.author: tomfitz
9+
10+
---
11+
# Create Resource Manager parameter file
12+
13+
Rather than passing parameters as inline values in your script, you may find it easier to use a JSON file that contains the parameter values. This article shows how to create the parameter file.
14+
15+
## Parameter file
16+
17+
The parameter file has the following format:
18+
19+
```json
20+
{
21+
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
22+
"contentVersion": "1.0.0.0",
23+
"parameters": {
24+
"<first-parameter-name>": {
25+
"value": "<first-value>"
26+
},
27+
"<second-parameter-name>": {
28+
"value": "<second-value>"
29+
}
30+
}
31+
}
32+
```
33+
34+
Notice that the parameter values are stored as plain text in the parameter file. This approach works for values that aren't sensitive, such as specifying the SKU for a resource. It doesn't work for sensitive values, such as passwords. If you need to pass a sensitive value as a parameter, store the value in a key vault, and reference the key vault in your parameter file. The sensitive value is securely retrieved during deployment.
35+
36+
The following parameter file includes a plain text value and a value that is stored in a key vault.
37+
38+
```json
39+
{
40+
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
41+
"contentVersion": "1.0.0.0",
42+
"parameters": {
43+
"<first-parameter-name>": {
44+
"value": "<first-value>"
45+
},
46+
"<second-parameter-name>": {
47+
"reference": {
48+
"keyVault": {
49+
"id": "<resource-id-key-vault>"
50+
},
51+
"secretName": "<secret-name>"
52+
}
53+
}
54+
}
55+
}
56+
```
57+
58+
For more information about using values from a key vault, see [Use Azure Key Vault to pass secure parameter value during deployment](resource-manager-keyvault-parameter.md).
59+
60+
## Define parameter values
61+
62+
To figure out how to define the parameter values, open the template you're deploying. Look at the parameters section of the template. The following example shows the parameters from a template.
63+
64+
```json
65+
"parameters": {
66+
"storagePrefix": {
67+
"type": "string",
68+
"maxLength": 11
69+
},
70+
"storageAccountType": {
71+
"type": "string",
72+
"defaultValue": "Standard_LRS",
73+
"allowedValues": [
74+
"Standard_LRS",
75+
"Standard_GRS",
76+
"Standard_ZRS",
77+
"Premium_LRS"
78+
]
79+
}
80+
}
81+
```
82+
83+
The first detail to notice is the name of each parameter. The values in your parameter file must match the names.
84+
85+
```json
86+
{
87+
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
88+
"contentVersion": "1.0.0.0",
89+
"parameters": {
90+
"storagePrefix": {
91+
},
92+
"storageAccountType": {
93+
}
94+
}
95+
}
96+
```
97+
98+
Notice the type of the parameter. The values in your parameter file must have the same types. For this template, you can provide both parameters as strings.
99+
100+
```json
101+
{
102+
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
103+
"contentVersion": "1.0.0.0",
104+
"parameters": {
105+
"storagePrefix": {
106+
"value": ""
107+
},
108+
"storageAccountType": {
109+
"value": ""
110+
}
111+
}
112+
}
113+
```
114+
115+
Next, look for a default value. If a parameter has a default value, you can provide a value but you don't have to.
116+
117+
```json
118+
{
119+
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
120+
"contentVersion": "1.0.0.0",
121+
"parameters": {
122+
"storagePrefix": {
123+
"value": "" // This value must be provided.
124+
},
125+
"storageAccountType": {
126+
"value": "" // This value is optional. Template will use default value if not provided.
127+
}
128+
}
129+
}
130+
```
131+
132+
Finally, look at the allowed values and any restrictions like max length. They tell you the range of values you can provide for the parameter.
133+
134+
```json
135+
{
136+
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
137+
"contentVersion": "1.0.0.0",
138+
"parameters": {
139+
"storagePrefix": {
140+
"value": "storage"
141+
},
142+
"storageAccountType": {
143+
"value": "Standard_ZRS"
144+
}
145+
}
146+
}
147+
```
148+
149+
## Parameter type formats
150+
151+
The following example shows the formats of different parameter types.
152+
153+
```json
154+
{
155+
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
156+
"contentVersion": "1.0.0.0",
157+
"parameters": {
158+
"exampleString": {
159+
"value": "test string"
160+
},
161+
"exampleInt": {
162+
"value": 4
163+
},
164+
"exampleBool": {
165+
"value": true
166+
},
167+
"exampleArray": {
168+
"value": [
169+
"value 1",
170+
"value 2"
171+
]
172+
},
173+
"exampleObject": {
174+
"value": {
175+
"property1": "value1",
176+
"property2": "value2"
177+
}
178+
}
179+
}
180+
}
181+
```
182+
183+
## File name
184+
185+
The general convention for naming the parameter file is to add **.parameters** to the template name. For example, if your template is named **azuredeploy.json**, your parameter file is named **azuredeploy.parameters.json**. This naming convention helps you see the connection between the template and the parameters.
186+
187+
To deploy to different environments, create more than one parameter file. When naming the parameter file, add a way to identify its use. For example, use **azuredeploy.parameters-dev.json** and **azuredeploy.parameters-prod.json**
188+
189+
190+
## Parameter precedence
191+
192+
You can use inline parameters and a local parameter file in the same deployment operation. For example, you can specify some values in the local parameter file and add other values inline during deployment. If you provide values for a parameter in both the local parameter file and inline, the inline value takes precedence.
193+
194+
However, when you use an external parameter file, you can't pass other values either inline or from a local file. All inline parameters are ignored. Provide all parameter values in the external file.
195+
196+
## Parameter name conflicts
197+
198+
If your template includes a parameter with the same name as one of the parameters in the PowerShell command, PowerShell presents the parameter from your template with the postfix **FromTemplate**. For example, a parameter named **ResourceGroupName** in your template conflicts with the **ResourceGroupName** parameter in the [New-AzResourceGroupDeployment](/powershell/module/az.resources/new-azresourcegroupdeployment) cmdlet. You're prompted to provide a value for **ResourceGroupNameFromTemplate**. You can avoid this confusion by using parameter names that aren't used for deployment commands.
199+
200+
## Next steps
201+
202+
- To understand how to define parameters in your template, see [Understand the structure and syntax of Azure Resource Manager templates](resource-group-authoring-templates.md).
203+
- For more information about using values from a key vault, see [Use Azure Key Vault to pass secure parameter value during deployment](resource-manager-keyvault-parameter.md).
204+

articles/azure-resource-manager/toc.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,6 @@
9797
- name: Modularize templates
9898
displayName: linked templates, nested templates
9999
href: resource-group-linked-templates.md
100-
- name: Manage secrets
101-
displayname: key vault
102-
href: resource-manager-keyvault-parameter.md
103100
- name: Create multiple instances
104101
href: resource-group-create-multiple.md
105102
- name: Use template extensions
@@ -124,6 +121,13 @@
124121
href: secure-template-with-sas-token.md
125122
- name: Deploy to multiple resource groups or subscriptions
126123
href: resource-manager-cross-resource-group-deployment.md
124+
- name: Provide parameters
125+
items:
126+
- name: Create parameter file
127+
href: resource-manager-parameter-files.md
128+
- name: Pass sensitive values
129+
displayname: key vault
130+
href: resource-manager-keyvault-parameter.md
127131
- name: CI/CD
128132
items:
129133
- name: VS project with pipelines

0 commit comments

Comments
 (0)