Skip to content

Commit 02616df

Browse files
Merge pull request #310278 from mumian/1008-type-expression
ARM template expression limitation
2 parents 2a2875e + 57c824e commit 02616df

1 file changed

Lines changed: 50 additions & 1 deletion

File tree

articles/azure-resource-manager/templates/template-expressions.md

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Template syntax and expressions
33
description: Describes the declarative JSON syntax for Azure Resource Manager templates (ARM templates).
44
ms.topic: article
55
ms.custom: devx-track-arm-template
6-
ms.date: 04/28/2025
6+
ms.date: 01/09/2026
77
---
88

99
# Syntax and expressions in ARM templates
@@ -12,6 +12,55 @@ The basic syntax of the Azure Resource Manager template (ARM template) is JavaSc
1212

1313
A template expression can't exceed 24,576 characters.
1414

15+
## Compile-time constrains
16+
17+
Template expressions are evaluated at runtime, but certain properties in ARM templates must be known at compile time and therefore cannot use expressions. These properties must be specified as literal strings so the deployment engine and compiler can validate resource schemas, dependencies, and supported properties before any expressions are evaluated.
18+
19+
Properties that must be compile-time literals include:
20+
21+
- The `type` and `apiVersion` of a resource.
22+
- The `name` of variables, parameters, and outputs.
23+
- Extension references.
24+
25+
The following ARM template failed because the `type` property of the resource uses an expression:
26+
27+
```json
28+
{
29+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
30+
"contentVersion": "1.0.0.0",
31+
"parameters": {
32+
"storageAccountName": {
33+
"type": "string",
34+
"defaultValue": "[format('storage{0}', uniqueString(resourceGroup().id))]"
35+
},
36+
"location": {
37+
"type": "string",
38+
"defaultValue": "[resourceGroup().location]"
39+
},
40+
"resourceProvider": {
41+
"type": "string",
42+
"defaultValue": "Microsoft.Storage"
43+
},
44+
"resourceType": {
45+
"type": "string",
46+
"defaultValue": "storageAccounts"
47+
}
48+
},
49+
"resources": [
50+
{
51+
"type": "[format('{0}/{1}', parameters('resourceProvider'), parameters('resourceType'))]",
52+
"apiVersion": "2025-06-01",
53+
"name": "[parameters('storageAccountName')]",
54+
"location": "[parameters('location')]",
55+
"sku": {
56+
"name": "Standard_LRS"
57+
},
58+
"kind": "StorageV2"
59+
}
60+
]
61+
}
62+
```
63+
1564
## Use functions
1665

1766
Azure Resource Manager provides [functions](template-functions.md) that you can use in a template. The following example shows an expression that uses a function in the default value of a parameter:

0 commit comments

Comments
 (0)