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
- Returns the type of[managed identity](/entra/identity/managed-identities-azure-resources/overview) enabled on the resource.
106
+
- Valid values from managed identity: `None`, `SystemAssigned`, `SystemAssigned, UserAssigned`, and `UserAssigned`.
107
+
-`identity.type` can be used with any supported [conditions](#conditions) of a policy rule. For example, a policy with [deny effect](./effect-deny.md) could block requests based on the existence of an identity or based on the specific value of the identity type. An example policy rule that checks for existence of `identity.type` is the built-in Policy definition [Automation Account should have Managed Identity](https://portal.azure.com/#blade/Microsoft_Azure_Policy/PolicyDetailBlade/definitionId/%2Fproviders%2FMicrosoft.Authorization%2FpolicyDefinitions%2Fdea83a72-443c-4292-83d5-54a2f98749c0) with ID `dea83a72-443c-4292-83d5-54a2f98749c0`.
108
108
-`tags`
109
-
-`tags['<tagName>']`
110
-
- This bracket syntax supports tag names that have punctuation such as a hyphen, period, or space.
111
-
- Where `tagName` is the name of the tag to validate the condition for.
112
-
- Examples: `tags['Acct.CostCenter']` where `Acct.CostCenter` is the name of the tag.
113
-
-`tags['''<tagName>''']`
114
-
- This bracket syntax supports tag names that have apostrophes in it by escaping with double apostrophes.
115
-
- Where `tagName` is the name of the tag to validate the condition for.
116
-
- Example: `tags['''My.Apostrophe.Tag''']` where `'My.Apostrophe.Tag'` is the name of the tag.
117
-
118
-
> [!NOTE]
119
-
> `tags.<tagName>`, `tags[tagName]`, and `tags[tag.with.dots]` are still acceptable ways of
120
-
> declaring a tags field. However, the preferred expressions are those listed above.
121
-
- property aliases - for a list, see [Aliases](./definition-structure-alias.md).
122
-
> [!NOTE]
123
-
> In `field` expressions referring to array alias `[*]` each element in the array is evaluated
124
-
> individually with logical `and` between elements. For more information, see
Conditions that use `field` expressions can replace the legacy policy definition syntax `"source": "action"`, which used to work for write operations. For example, this is no longer supported:
109
+
-`tags['<tagName>']`
110
+
- This bracket syntax supports tag names that have punctuation such as a hyphen, period, or space.
111
+
- Where `tagName` is the name of the tag to validate the condition for.
112
+
- Examples: `tags['Acct.CostCenter']` where `Acct.CostCenter` is the name of the tag.
113
+
-`tags['''<tagName>''']`
114
+
- This bracket syntax supports tag names that have apostrophes in it by escaping with double apostrophes.
115
+
- Where `tagName` is the name of the tag to validate the condition for.
116
+
- Example: `tags['''My.Apostrophe.Tag''']` where `'My.Apostrophe.Tag'` is the name of the tag.
117
+
-`tags.<tagName>`, `tags[tagName]`, and `tags[tag.with.dots]` are acceptable ways to declare a `tags` field but the preferred expressions are the prior examples.
118
+
119
+
- property aliases
120
+
- For a list, see [Aliases](./definition-structure-alias.md).
121
+
- In `field` expressions referring to array alias `[*]` each element in the array is evaluated individually with logical `and` between elements. For more information, see [Referencing array resource properties](../how-to/author-policies-for-arrays.md#referencing-array-resource-properties).
122
+
123
+
### Field expressions
124
+
125
+
Conditions that use `field` expressions can replace the legacy policy definition syntax `"source": "action"`, which used to work for write operations. For example, the following code is no longer supported:
129
126
130
127
```json
131
128
{
@@ -135,6 +132,7 @@ Conditions that use `field` expressions can replace the legacy policy definition
135
132
```
136
133
137
134
But the desired behavior can be achieved using `field` logic:
135
+
138
136
```json
139
137
{
140
138
"field": "type",
@@ -181,7 +179,7 @@ Conditions that evaluate whether a value meets certain criteria can be formed us
181
179
> is an implicit `deny`. For more information, see
182
180
> [avoiding template failures](#avoiding-template-failures). Use
183
181
> [enforcementMode](./assignment-structure.md#enforcement-mode) of `doNotEnforce` to prevent
184
-
> impact of a failed evaluation on new or updated resources while testing and validating a new
182
+
> the effect of a failed evaluation on new or updated resources while testing and validating a new
185
183
> policy definition.
186
184
187
185
### Value examples
@@ -243,7 +241,7 @@ The use of _template functions_ in `value` allows for many complex nested functi
243
241
}
244
242
```
245
243
246
-
The example policy rule above uses [substring()](../../../azure-resource-manager/templates/template-functions-string.md#substring) to compare the first three characters of `name` to `abc`. If `name` is shorter than three characters, the `substring()` function results in an error. This error causes the policy to become a `deny` effect.
244
+
The previous example policy rule uses [substring()](../../../azure-resource-manager/templates/template-functions-string.md#substring) to compare the first three characters of `name` to `abc`. If `name` is shorter than three characters, the `substring()` function results in an error. This error causes the policy to become a `deny` effect.
247
245
248
246
Instead, use the [if()](../../../azure-resource-manager/templates/template-functions-logical.md#if) function to check if the first three characters of `name` equal `abc` without allowing a `name` shorter than three characters to cause an error:
249
247
@@ -265,7 +263,7 @@ With the revised policy rule, `if()` checks the length of `name` before trying t
265
263
266
264
## Count
267
265
268
-
Conditions that count how many members of an array meet certain criteria can be formed using a `count` expression. Common scenarios are checking whether 'at least one of', 'exactly one of', 'all of', or 'none of' the array members satisfy a condition. The `count` evaluates each array member for a condition expression and sums the _true_ results, which is then compared to the expression operator.
266
+
Conditions that count how many members of an array meet certain criteria can be formed using a `count` expression. Common scenarios are checking whether _at least one of_, _exactly one of_, _all of_, or _none of_ the array members satisfy a condition. The `count` evaluates each array member for a condition expression and sums the _true_ results, which is then compared to the expression operator.
269
267
270
268
### Field count
271
269
@@ -323,15 +321,15 @@ The `current()` function is only available inside the `count.where` condition. I
323
321
**Value count usage**
324
322
325
323
-`current(<index name defined in count.name>)`. For example: `current('arrayMember')`.
326
-
-`current()`. Allowed only when the `value count` expression isn't a child of another `count` expression. Returns the same value as above.
324
+
-`current()`. Allowed only when the `value count` expression isn't a child of another `count` expression. Returns the same value as previous example.
327
325
328
326
If the value returned by the call is an object, property accessors are supported. For example: `current('objectArrayMember').property`.
329
327
330
328
**Field count usage**
331
329
332
330
-`current(<the array alias defined in count.field>)`. For example,
Functions can be used to introduce additional logic into a policy rule. They are resolved within the policy rule of a policy definition and within [parameter values assigned to policy definitions in an initiative](initiative-definition-structure.md#passing-a-parameter-value-to-a-policy-definition).
589
+
Functions can be used to introduce more logic into a policy rule. Functions are resolved within the policy rule of a policy definition and within [parameter values assigned to policy definitions in an initiative](initiative-definition-structure.md#passing-a-parameter-value-to-a-policy-definition).
592
590
593
591
All [Resource Manager template functions](../../../azure-resource-manager/templates/template-functions.md) are available to use within a policy rule, except the following functions and user-defined functions:
594
592
@@ -627,12 +625,12 @@ The following function is available to use in a policy rule, but differs from us
627
625
The following functions are only available in policy rules:
628
626
629
627
-`addDays(dateTime, numberOfDaysToAdd)`
630
-
-`dateTime`: [Required] string - String in the Universal ISO 8601 DateTime format 'yyyy-MM-ddTHH:mm:ss.FFFFFFFZ'
631
-
-`numberOfDaysToAdd`: [Required] integer - Number of days to add
628
+
-`dateTime`: [Required] string - String in the Universal ISO 8601 DateTime format `yyyy-MM-ddTHH:mm:ss.FFFFFFFZ`.
629
+
-`numberOfDaysToAdd`: [Required] integer - Number of days to add.
632
630
633
631
-`field(fieldName)`
634
632
-`fieldName`: [Required] string - Name of the [field](./definition-structure-policy-rule.md#fields) to retrieve
635
-
- Returns the value of that field from the resource that is being evaluated by the If condition.
633
+
- Returns the value of that field from the resource evaluated by the `if` condition.
636
634
-`field` is primarily used with `auditIfNotExists` and `deployIfNotExists` to reference fields on the resource that are being evaluated. An example of this use can be seen in the [DeployIfNotExists example](effect-deploy-if-not-exists.md#deployifnotexists-example).
637
635
638
636
-`requestContext().apiVersion`
@@ -643,7 +641,7 @@ The following functions are only available in policy rules:
@@ -661,7 +659,7 @@ The following functions are only available in policy rules:
661
659
- Range defined by start and end IP addresses (examples: `192.168.0.1-192.168.0.9`, `2001:0DB8::-2001:0DB8::3:FFFF`)
662
660
663
661
- `current(indexName)`
664
-
- Special function that may only be used inside [count expressions](./definition-structure-policy-rule.md#count).
662
+
- Special function that might only be used inside [count expressions](./definition-structure-policy-rule.md#count).
665
663
666
664
### Policy function example
667
665
@@ -685,9 +683,9 @@ This policy rule example uses the `resourceGroup` resource function to get the `
685
683
686
684
### Limits enforced during authoring
687
685
688
-
Limits to the structure of policy rules are enforced during the authoring or assignment of a policy. Attempts to create or assign policy definitions that exceed these limits will fail.
686
+
Limits to the structure of policy rules are enforced during the authoring or assignment of a policy. Attempts to create or assign policy definitions that exceed these limits fail.
689
687
690
-
| Limit | Value |Additional details|
688
+
| Limit | Value |Details|
691
689
|:---|:---|:---|
692
690
| Condition expressions in the `if` condition | 4096 ||
693
691
| Condition expressions in the `then` block | 128 | Applies to the `existenceCondition` of `auditIfNotExists` and `deployIfNotExists` policies |
@@ -697,11 +695,11 @@ Limits to the structure of policy rules are enforced during the authoring or ass
697
695
| Policy functions expression string length | 81920 | Example: the length of `"[function(....)]"`|
698
696
|`Field count` expressions per array | 5 ||
699
697
|`Value count` expressions per policy rule | 10 ||
700
-
|`Value count` expression iteration count | 100 |For nested `Value count` expressions, this also includes the iteration count of the parent expression |
698
+
|`Value count` expression iteration count | 100 |Nested `Value count` expressionsalso include the iteration count of the parent expression.|
701
699
702
700
### Limits enforced during evaluation
703
701
704
-
Limits to the size of objects that are processed by policy functions during policy evaluation. These limits can't always be enforced during authoring since they depend on the evaluated content. For example:
702
+
Limits to the size of objects processed by policy functions during policy evaluation. These limits can't always be enforced during authoring since they depend on the evaluated content. For example:
705
703
706
704
```json
707
705
{
@@ -719,7 +717,7 @@ The length of the string created by the `concat()` function depends on the value
719
717
| Number of nodes of complex objects provided as a parameter to, or returned by a function | 32768 |`[concat(field('largeArray1'), field('largeArray2'))]`|
720
718
721
719
> [!WARNING]
722
-
> Policy that exceed the above limits during evaluation will effectively become a `deny` policy and can block incoming requests.
720
+
> Policies that exceed the limits during evaluation will effectively become a `deny` policy and can block incoming requests.
723
721
> When writing policies with complex functions, be mindful of these limits and test your policies against resources that have the potential to exceed them.
0 commit comments