Skip to content

Commit 8b4f2c9

Browse files
authored
Merge pull request #104288 from tfitzmac/0213funcs
add function scope
2 parents a7d8075 + dcfe2a1 commit 8b4f2c9

File tree

3 files changed

+31
-9
lines changed

3 files changed

+31
-9
lines changed

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Template syntax and expressions
33
description: Describes the declarative JSON syntax for Azure Resource Manager templates.
44
ms.topic: conceptual
5-
ms.date: 02/10/2020
5+
ms.date: 02/13/2020
66
---
77

88
# Syntax and expressions in Azure Resource Manager templates
@@ -11,11 +11,9 @@ The basic syntax of the template is JSON. However, you can use expressions to ex
1111

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

14-
Expressions support json('null') and properties support a literal value of null. In both cases, Resource Manager templates treat it as if the property is not present.
15-
1614
## Use functions
1715

18-
The following example shows an expression in the default value of a parameter:
16+
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:
1917

2018
```json
2119
"parameters": {
@@ -36,6 +34,12 @@ To pass a string value as a parameter to a function, use single quotes.
3634
"name": "[concat('storage', uniqueString(resourceGroup().id))]"
3735
```
3836

37+
Most functions work the same whether deployed to a resource group, subscription, management group, or tenant. The following functions have restrictions based on the scope:
38+
39+
* [resourceGroup](template-functions-resource.md#resourcegroup) - can only be used in deployments to a resource group.
40+
* [resourceId](template-functions-resource.md#resourceid) - can be used at any scope, but the valid parameters change depending on the scope.
41+
* [subscription](template-functions-resource.md#subscription) - can only be used in deployments to a resource group or subscription.
42+
3943
## Escape characters
4044

4145
To have a literal string start with a left bracket `[` and end with a right bracket `]`, but not have it interpreted as an expression, add an extra bracket to start the string with `[[`. For example, the variable:
@@ -62,6 +66,15 @@ To escape double quotes in an expression, such as adding a JSON object in the te
6266
},
6367
```
6468

69+
## Null values
70+
71+
To set a property to null, you can use **null** or **[json('null')]**. The [json function](template-functions-array.md#json) returns an empty object when you provide `null` as the parameter. In both cases, Resource Manager templates treat it as if the property is not present.
72+
73+
```json
74+
"stringValue": null,
75+
"objectValue": "[json('null')]"
76+
```
77+
6578
## Next steps
6679

6780
* For the full list of template functions, see [Azure Resource Manager template functions](template-functions.md).

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ Returns the unique identifier of a resource. You use this function when the reso
753753

754754
| Parameter | Required | Type | Description |
755755
|:--- |:--- |:--- |:--- |
756-
| subscriptionId |No |string (In GUID format) |Default value is the current subscription. Specify this value when you need to retrieve a resource in another subscription. |
756+
| subscriptionId |No |string (In GUID format) |Default value is the current subscription. Specify this value when you need to retrieve a resource in another subscription. Only provide this value when deploying at the scope of a resource group or subscription. |
757757
| resourceGroupName |No |string |Default value is current resource group. Specify this value when you need to retrieve a resource in another resource group. Only provide this value when deploying at the scope of a resource group. |
758758
| resourceType |Yes |string |Type of resource including resource provider namespace. |
759759
| resourceName1 |Yes |string |Name of resource. |

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22
title: Template functions
33
description: Describes the functions to use in an Azure Resource Manager template to retrieve values, work with strings and numerics, and retrieve deployment information.
44
ms.topic: conceptual
5-
ms.date: 11/19/2019
5+
ms.date: 02/13/2020
66
---
77
# Azure Resource Manager template functions
88

99
This article describes all the functions you can use in an Azure Resource Manager template. For information about using functions in your template, see [template syntax](template-expressions.md).
1010

1111
To create your own functions, see [User-defined functions](template-syntax.md#functions).
1212

13+
Most functions work the same when deployed to a resource group, subscription, management group, or tenant. A few functions can't be used in all scopes. They're noted in the lists below.
14+
1315
<a id="array" aria-hidden="true" />
1416
<a id="coalesce" aria-hidden="true" />
1517
<a id="concatarray" aria-hidden="true" />
@@ -29,6 +31,7 @@ To create your own functions, see [User-defined functions](template-syntax.md#fu
2931
<a id="union" aria-hidden="true" />
3032

3133
## Array and object functions
34+
3235
Resource Manager provides several functions for working with arrays and objects.
3336

3437
* [array](template-functions-array.md#array)
@@ -56,6 +59,7 @@ Resource Manager provides several functions for working with arrays and objects.
5659
<a id="greaterorequals" aria-hidden="true" />
5760

5861
## Comparison functions
62+
5963
Resource Manager provides several functions for making comparisons in your templates.
6064

6165
* [equals](template-functions-comparison.md#equals)
@@ -69,6 +73,7 @@ Resource Manager provides several functions for making comparisons in your templ
6973
<a id="variables" aria-hidden="true" />
7074

7175
## Deployment value functions
76+
7277
Resource Manager provides the following functions for getting values from sections of the template and values related to the deployment:
7378

7479
* [deployment](template-functions-deployment.md#deployment)
@@ -83,6 +88,7 @@ Resource Manager provides the following functions for getting values from sectio
8388
<a id="or" aria-hidden="true" />
8489

8590
## Logical functions
91+
8692
Resource Manager provides the following functions for working with logical conditions:
8793

8894
* [and](template-functions-logical.md#and)
@@ -103,6 +109,7 @@ Resource Manager provides the following functions for working with logical condi
103109
<a id="sub" aria-hidden="true" />
104110

105111
## Numeric functions
112+
106113
Resource Manager provides the following functions for working with integers:
107114

108115
* [add](template-functions-numeric.md#add)
@@ -128,6 +135,7 @@ Resource Manager provides the following functions for working with integers:
128135
<a id="tenantResourceId" aria-hidden="true" />
129136

130137
## Resource functions
138+
131139
Resource Manager provides the following functions for getting resource values:
132140

133141
* [extensionResourceId](template-functions-resource.md#extensionresourceid)
@@ -137,9 +145,9 @@ Resource Manager provides the following functions for getting resource values:
137145
* [list*](template-functions-resource.md#list)
138146
* [providers](template-functions-resource.md#providers)
139147
* [reference](template-functions-resource.md#reference)
140-
* [resourceGroup](template-functions-resource.md#resourcegroup)
141-
* [resourceId](template-functions-resource.md#resourceid)
142-
* [subscription](template-functions-resource.md#subscription)
148+
* [resourceGroup](template-functions-resource.md#resourcegroup) - can only be used in deployments to a resource group.
149+
* [resourceId](template-functions-resource.md#resourceid) - can be used at any scope, but the valid parameters change depending on the scope.
150+
* [subscription](template-functions-resource.md#subscription) - can only be used in deployments to a resource group or subscription.
143151
* [subscriptionResourceId](template-functions-resource.md#subscriptionresourceid)
144152
* [tenantResourceId](template-functions-resource.md#tenantresourceid)
145153

@@ -175,6 +183,7 @@ Resource Manager provides the following functions for getting resource values:
175183
<a id="uricomponenttostring" aria-hidden="true" />
176184

177185
## String functions
186+
178187
Resource Manager provides the following functions for working with strings:
179188

180189
* [base64](template-functions-string.md#base64)

0 commit comments

Comments
 (0)