Skip to content

Commit 89bac18

Browse files
committed
added parameter file
1 parent 398ace1 commit 89bac18

File tree

2 files changed

+206
-3
lines changed

2 files changed

+206
-3
lines changed
Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
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, you need to open the template you are 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+
Then, notice the type of the parameter. The values in your parameter file must have the same types. For this template, you can provide two parameters that are both 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+
You can create more than one parameter file, and then pass in the appropriate parameter file for the scenario.
150+
151+
## Parameter formats
152+
153+
The following example shows the formats of different parameter types.
154+
155+
```json
156+
{
157+
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
158+
"contentVersion": "1.0.0.0",
159+
"parameters": {
160+
"exampleString": {
161+
"value": "test string"
162+
},
163+
"exampleInt": {
164+
"value": 4
165+
},
166+
"exampleBool": {
167+
"value": true
168+
},
169+
"exampleArray": {
170+
"value": [
171+
"value 1",
172+
"value 2"
173+
]
174+
},
175+
"exampleObject": {
176+
"value": {
177+
"property1": "value1",
178+
"property2": "value2"
179+
}
180+
}
181+
}
182+
}
183+
```
184+
185+
## Parameter precedence
186+
187+
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.
188+
189+
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.
190+
191+
## Parameter name conflicts
192+
193+
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**. In general, you should avoid this confusion by not naming parameters with the same name as parameters used for deployment operations.
194+
195+
## Next steps
196+
197+
- 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).
198+
- 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).
199+

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)