Skip to content

Commit 72ff901

Browse files
committed
updates invalid template doc
1 parent ceb26d3 commit 72ff901

File tree

1 file changed

+36
-24
lines changed

1 file changed

+36
-24
lines changed
Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
---
22
title: Invalid template errors
3-
description: Describes how to resolve invalid template errors when deploying Azure Resource Manager templates.
3+
description: Describes how to resolve invalid template errors when deploying Bicep files or Azure Resource Manager templates (ARM templates).
44
ms.topic: troubleshooting
5-
ms.date: 11/11/2021
5+
ms.date: 11/15/2021
66
---
7+
78
# Resolve errors for invalid template
89

9-
This article describes how to resolve invalid template errors.
10+
This article describes how to resolve invalid template errors for Bicep files and Azure Resource Manager templates (ARM templates).
1011

1112
## Symptom
1213

13-
When deploying a template, you receive an error indicating:
14+
When a template is deployed, you receive an error that indicates:
1415

15-
```
16+
```Output
1617
Code=InvalidTemplate
1718
Message=<varies>
1819
```
@@ -29,20 +30,29 @@ This error can result from several different types of errors. They usually invol
2930

3031
If you receive an error message that indicates the template failed validation, you may have a syntax problem in your template.
3132

32-
```
33+
```Output
3334
Code=InvalidTemplate
3435
Message=Deployment template validation failed
3536
```
3637

37-
This error is easy to make because template expressions can be intricate. For example, the following name assignment for a storage account has one set of brackets, three functions, three sets of parentheses, one set of single quotes, and one property:
38+
Syntax errors can occur because template expressions have many elements. For example, the name assignment for a storage account includes pairs of single or double quotes, curly braces, square brackets, and parentheses. Expressions also contain functions and characters like dollar signs, commas, and dots.
39+
40+
41+
# [Bicep](#tab/bicep)
42+
43+
```bicep
44+
name: 'storage${uniqueString(resourceGroup().id)}'
45+
```
46+
47+
# [JSON](#tab/json)
3848

3949
```json
4050
"name": "[concat('storage', uniqueString(resourceGroup().id))]",
4151
```
4252

43-
If you don't provide the matching syntax, the template produces a value that is different than your intention.
53+
---
4454

45-
When you receive this type of error, carefully review the expression syntax. Consider using a JSON editor like [Visual Studio](../templates/create-visual-studio-deployment-project.md) or [Visual Studio Code](../templates/quickstart-create-templates-use-visual-studio-code.md), which can warn you about syntax errors.
55+
When you receive this type of error, review the expression's syntax. To identify template errors, you can use [Visual Studio Code](https://code.visualstudio.com) with the latest [Bicep extension](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-bicep) or [Azure Resource Manager Tools extension](https://marketplace.visualstudio.com/items?itemName=msazurermtools.azurerm-vscode-tools).
4656

4757
<a id="incorrect-segment-lengths"></a>
4858

@@ -54,49 +64,51 @@ Another invalid template error occurs when the resource name isn't in the correc
5464

5565
## Solution 3 - parameter isn't valid
5666

57-
If you provide a parameter value that isn't one of the allowed values, you receive a message similar to the following error:
67+
You can specify a parameter's allowed values in a template. During deployment, if you provide a value that isn't an allowed value, you receive a message similar to the following error:
5868

59-
```
69+
```Output
6070
Code=InvalidTemplate;
6171
Message=Deployment template validation failed: 'The provided value {parameter value}
6272
for the template parameter {parameter name} is not valid. The parameter value is not
6373
part of the allowed values
6474
```
6575

66-
Double check the allowed values in the template, and provide one during deployment. For more information about allowed parameter values, see [Parameters section of Azure Resource Manager templates](../templates/syntax.md#parameters).
76+
Check the template for the parameter's allowed values, and use an allowed value during deployment. For more information, see allowed values for [Bicep](../bicep/parameters.md#allowed-values) or [ARM templates](../templates/parameters.md#allowed-values).
6777

6878
<a id="too-many-resource-groups"></a>
6979

7080
## Solution 4 - Too many target resource groups
7181

72-
You may see this error in earlier deployments because you were limited to five target resource groups in a single deployment. In May 2020, that limit was increased to 800 resource groups. For more information, see [Deploy Azure resources to more than one subscription or resource group](../templates/deploy-to-resource-group.md).
82+
You may see this error in earlier deployments because you were limited to five target resource groups in a single deployment. In May 2020, that limit was increased to 800 resource groups. For more information, see how to deploy to multiple resource groups for [Bicep](../bicep/deploy-to-resource-group.md#deploy-to-multiple-resource-groups) or [ARM templates](../templates/deploy-to-resource-group.md#deploy-to-multiple-resource-groups).
7383

7484
<a id="circular-dependency"></a>
7585

7686
## Solution 5 - circular dependency detected
7787

7888
You receive this error when resources depend on each other in a way that prevents the deployment from starting. A combination of interdependencies makes two or more resource wait for other resources that are also waiting. For example, resource1 depends on resource3, resource2 depends on resource1, and resource3 depends on resource2. You can usually solve this problem by removing unnecessary dependencies.
7989

90+
Bicep creates an implicit dependency when one resource uses the symbolic name of another resource. An explicit dependency using `dependsOn` usually isn't necessary. For more information, see Bicep [dependencies](../bicep/resource-declaration.md#dependencies).
91+
8092
To solve a circular dependency:
8193

8294
1. In your template, find the resource identified in the circular dependency.
83-
2. For that resource, examine the **dependsOn** property and any uses of the **reference** function to see which resources it depends on.
84-
3. Examine those resources to see which resources they depend on. Follow the dependencies until you notice a resource that depends on the original resource.
85-
5. For the resources involved in the circular dependency, carefully examine all uses of the **dependsOn** property to identify any dependencies that aren't needed. Remove those dependencies. If you're unsure that a dependency is needed, try removing it.
86-
6. Redeploy the template.
95+
1. For that resource, examine the `dependsOn` property and any uses of the `reference` function to see which resources it depends on.
96+
1. Examine those resources to see which resources they depend on. Follow the dependencies until you notice a resource that depends on the original resource.
97+
1. For the resources involved in the circular dependency, carefully examine all uses of the `dependsOn` property to identify any dependencies that aren't needed. Remove those dependencies. If you're unsure that a dependency is needed, try removing it.
98+
1. Redeploy the template.
8799

88-
Removing values from the **dependsOn** property can cause errors when you deploy the template. If you get an error, add the dependency back into the template.
100+
Removing values from the `dependsOn` property can cause errors when you deploy the template. If you get an error, add the dependency back into the template.
89101

90102
If that approach doesn't solve the circular dependency, consider moving part of your deployment logic into child resources (such as extensions or configuration settings). Configure those child resources to deploy after the resources involved in the circular dependency. For example, suppose you're deploying two virtual machines but you must set properties on each one that refer to the other. You can deploy them in the following order:
91103

92104
1. vm1
93-
2. vm2
94-
3. Extension on vm1 depends on vm1 and vm2. The extension sets values on vm1 that it gets from vm2.
95-
4. Extension on vm2 depends on vm1 and vm2. The extension sets values on vm2 that it gets from vm1.
105+
1. vm2
106+
1. Extension on vm1 depends on vm1 and vm2. The extension sets values on vm1 that it gets from vm2.
107+
1. Extension on vm2 depends on vm1 and vm2. The extension sets values on vm2 that it gets from vm1.
96108

97109
The same approach works for App Service apps. Consider moving configuration values into a child resource of the app resource. You can deploy two web apps in the following order:
98110

99111
1. webapp1
100-
2. webapp2
101-
3. config for webapp1 depends on webapp1 and webapp2. It contains app settings with values from webapp2.
102-
4. config for webapp2 depends on webapp1 and webapp2. It contains app settings with values from webapp1.
112+
1. webapp2
113+
1. Configuration for webapp1 depends on webapp1 and webapp2. It contains app settings with values from webapp2.
114+
1. Configuration for webapp2 depends on webapp1 and webapp2. It contains app settings with values from webapp1.

0 commit comments

Comments
 (0)