|
2 | 2 | title: Link templates for deployment
|
3 | 3 | description: Describes how to use linked templates in an Azure Resource Manager template to create a modular template solution. Shows how to pass parameters values, specify a parameter file, and dynamically created URLs.
|
4 | 4 | ms.topic: conceptual
|
5 |
| -ms.date: 12/10/2019 |
| 5 | +ms.date: 12/11/2019 |
6 | 6 | ---
|
7 | 7 | # Using linked and nested templates when deploying Azure resources
|
8 | 8 |
|
9 |
| -To deploy complex solutions, you can break your template into many related templates. You create a main template that connects all of the related templates, and deploy that main template. The related templates can be separate files or template syntax that is embedded within the main template. This article uses the term **linked template** to refer to a separate template file that is linked to from the main template. It uses the term **nested template** to refer to embedded template syntax within the main template. |
| 9 | +To deploy complex solutions, you can break your template into many related templates, and then deploy them together through a main template. The related templates can be separate files or template syntax that is embedded within the main template. This article uses the term **linked template** to refer to a separate template file that is linked to from the main template. It uses the term **nested template** to refer to embedded template syntax within the main template. |
10 | 10 |
|
11 | 11 | For small to medium solutions, a single template is easier to understand and maintain. You can see all the resources and values in a single file. For advanced scenarios, linked templates enable you to break down the solution into targeted components. You can easily reuse these templates for other scenarios.
|
12 | 12 |
|
@@ -86,11 +86,23 @@ The following example deploys a storage account through a nested template.
|
86 | 86 | }
|
87 | 87 | ```
|
88 | 88 |
|
89 |
| -## Scope for expressions in nested templates |
| 89 | +### Scope for expressions in nested templates |
90 | 90 |
|
91 |
| -When using a nested template, you must specify whether template expressions are evaluated within the scope of the parent template or the nested template. The scope determines how parameters, variables, and functions like [resourceGroup](resource-group-template-functions-resource.md#resourcegroup) and [subscription](resource-group-template-functions-resource.md#subscription) are resolved. |
| 91 | +When using a nested template, you can specify whether template expressions are evaluated within the scope of the parent template or the nested template. The scope determines how parameters, variables, and functions like [resourceGroup](resource-group-template-functions-resource.md#resourcegroup) and [subscription](resource-group-template-functions-resource.md#subscription) are resolved. |
92 | 92 |
|
93 |
| -You set the scope through the `expressionEvaluationOptions` property. By default, the `expressionEvaluationOptions` property is set to `outer`, which means it uses the parent template scope. In the preceding example, the scope isn't set so the value of the `storageAccountName` parameter is retrieved from the parent template. Set the value to `inner` to scope expressions to the nested template. |
| 93 | +You set the scope through the `expressionEvaluationOptions` property. By default, the `expressionEvaluationOptions` property is set to `outer`, which means it uses the parent template scope. Set the value to `inner` to scope expressions to the nested template. |
| 94 | + |
| 95 | +```json |
| 96 | +{ |
| 97 | + "apiVersion": "2017-05-10", |
| 98 | + "name": "nestedTemplate1", |
| 99 | + "type": "Microsoft.Resources/deployments", |
| 100 | + "properties": { |
| 101 | + "expressionEvaluationOptions": { |
| 102 | + "scope": "inner" |
| 103 | + }, |
| 104 | + ... |
| 105 | +``` |
94 | 106 |
|
95 | 107 | The following template demonstrates how template expressions are resolved according to the scope. It contains a variable named `exampleVar` that is defined in both the parent template and the nested template. It returns the value of the variable.
|
96 | 108 |
|
@@ -120,7 +132,6 @@ The following template demonstrates how template expressions are resolved accord
|
120 | 132 | "exampleVar": "from nested template"
|
121 | 133 | },
|
122 | 134 | "resources": [
|
123 |
| - |
124 | 135 | ],
|
125 | 136 | "outputs": {
|
126 | 137 | "testVar": {
|
|
0 commit comments