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
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).
4
4
ms.topic: troubleshooting
5
-
ms.date: 11/11/2021
5
+
ms.date: 11/15/2021
6
6
---
7
+
7
8
# Resolve errors for invalid template
8
9
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).
10
11
11
12
## Symptom
12
13
13
-
When deploying a template, you receive an error indicating:
14
+
When a template is deployed, you receive an error that indicates:
14
15
15
-
```
16
+
```Output
16
17
Code=InvalidTemplate
17
18
Message=<varies>
18
19
```
@@ -29,20 +30,29 @@ This error can result from several different types of errors. They usually invol
29
30
30
31
If you receive an error message that indicates the template failed validation, you may have a syntax problem in your template.
31
32
32
-
```
33
+
```Output
33
34
Code=InvalidTemplate
34
35
Message=Deployment template validation failed
35
36
```
36
37
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.
If you don't provide the matching syntax, the template produces a value that is different than your intention.
53
+
---
44
54
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).
46
56
47
57
<aid="incorrect-segment-lengths"></a>
48
58
@@ -54,49 +64,51 @@ Another invalid template error occurs when the resource name isn't in the correc
54
64
55
65
## Solution 3 - parameter isn't valid
56
66
57
-
If you provide a parametervalue 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:
58
68
59
-
```
69
+
```Output
60
70
Code=InvalidTemplate;
61
71
Message=Deployment template validation failed: 'The provided value {parameter value}
62
72
for the template parameter {parameter name} is not valid. The parameter value is not
63
73
part of the allowed values
64
74
```
65
75
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).
67
77
68
78
<aid="too-many-resource-groups"></a>
69
79
70
80
## Solution 4 - Too many target resource groups
71
81
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).
73
83
74
84
<aid="circular-dependency"></a>
75
85
76
86
## Solution 5 - circular dependency detected
77
87
78
88
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.
79
89
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
+
80
92
To solve a circular dependency:
81
93
82
94
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.
87
99
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.
89
101
90
102
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:
91
103
92
104
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.
96
108
97
109
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:
98
110
99
111
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