Skip to content

Commit dd0b728

Browse files
Merge pull request #296614 from davidsmatlak/ds-updates-policy-rule-doc-20250319
Updates Azure Policy identity.type field
2 parents bf02c57 + 0cfd98e commit dd0b728

File tree

1 file changed

+39
-41
lines changed

1 file changed

+39
-41
lines changed

articles/governance/policy/concepts/definition-structure-policy-rule.md

Lines changed: 39 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Details of the policy definition structure policy rules
33
description: Describes how policy definition policy rules are used to establish conventions for Azure resources in your organization.
4-
ms.date: 03/04/2025
4+
ms.date: 03/19/2025
55
ms.topic: conceptual
66
---
77

@@ -100,32 +100,29 @@ Conditions that evaluate whether the values of properties in the resource reques
100100
- Use **global** for resources that are location agnostic.
101101
- `id`
102102
- Returns the resource ID of the resource that is being evaluated.
103-
- Example: `/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/myRG/providers/Microsoft.KeyVault/vaults/myVault`
103+
- Example: `/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/myRG/providers/Microsoft.KeyVault/vaults/myVault`
104104
- `identity.type`
105-
- Returns the type of
106-
[managed identity](../../../active-directory/managed-identities-azure-resources/overview.md)
107-
enabled on the resource.
105+
- 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`.
108108
- `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
125-
> [Referencing array resource properties](../how-to/author-policies-for-arrays.md#referencing-array-resource-properties).
126-
127-
128-
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:
129126

130127
```json
131128
{
@@ -135,6 +132,7 @@ Conditions that use `field` expressions can replace the legacy policy definition
135132
```
136133

137134
But the desired behavior can be achieved using `field` logic:
135+
138136
```json
139137
{
140138
"field": "type",
@@ -181,7 +179,7 @@ Conditions that evaluate whether a value meets certain criteria can be formed us
181179
> is an implicit `deny`. For more information, see
182180
> [avoiding template failures](#avoiding-template-failures). Use
183181
> [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
185183
> policy definition.
186184
187185
### Value examples
@@ -243,7 +241,7 @@ The use of _template functions_ in `value` allows for many complex nested functi
243241
}
244242
```
245243

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.
247245

248246
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:
249247

@@ -265,7 +263,7 @@ With the revised policy rule, `if()` checks the length of `name` before trying t
265263

266264
## Count
267265

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.
269267

270268
### Field count
271269

@@ -323,15 +321,15 @@ The `current()` function is only available inside the `count.where` condition. I
323321
**Value count usage**
324322

325323
- `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.
327325

328326
If the value returned by the call is an object, property accessors are supported. For example: `current('objectArrayMember').property`.
329327

330328
**Field count usage**
331329

332330
- `current(<the array alias defined in count.field>)`. For example,
333331
`current('Microsoft.Test/resource/enumeratedArray[*]')`.
334-
- `current()`. Allowed only when the `field count` expression isn't a child of another `count` expression. Returns the same value as above.
332+
- `current()`. Allowed only when the `field count` expression isn't a child of another `count` expression. Returns the same value as previous examples.
335333
- `current(<alias of a property of the array member>)`. For example,
336334
`current('Microsoft.Test/resource/enumeratedArray[*].property')`.
337335

@@ -588,7 +586,7 @@ Policy:
588586

589587
## Policy functions
590588

591-
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).
592590

593591
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:
594592

@@ -627,12 +625,12 @@ The following function is available to use in a policy rule, but differs from us
627625
The following functions are only available in policy rules:
628626

629627
- `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.
632630

633631
- `field(fieldName)`
634632
- `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.
636634
- `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).
637635

638636
- `requestContext().apiVersion`
@@ -643,7 +641,7 @@ The following functions are only available in policy rules:
643641

644642
```json
645643
{
646-
"assignmentId": "/subscriptions/11111111-1111-1111-1111-111111111111/providers/Microsoft.Authorization/policyAssignments/myAssignment",
644+
"assignmentId": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/providers/Microsoft.Authorization/policyAssignments/myAssignment",
647645
"definitionId": "/providers/Microsoft.Authorization/policyDefinitions/34c877ad-507e-4c82-993e-3452a6e0ad3c",
648646
"setDefinitionId": "/providers/Microsoft.Authorization/policySetDefinitions/42a694ed-f65e-42b2-aa9e-8052e9740a92",
649647
"definitionReferenceId": "StorageAccountNetworkACLs"
@@ -661,7 +659,7 @@ The following functions are only available in policy rules:
661659
- Range defined by start and end IP addresses (examples: `192.168.0.1-192.168.0.9`, `2001:0DB8::-2001:0DB8::3:FFFF`)
662660

663661
- `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).
665663

666664
### Policy function example
667665

@@ -685,9 +683,9 @@ This policy rule example uses the `resourceGroup` resource function to get the `
685683

686684
### Limits enforced during authoring
687685

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.
689687

690-
| Limit | Value | Additional details |
688+
| Limit | Value | Details |
691689
|:---|:---|:---|
692690
| Condition expressions in the `if` condition | 4096 | |
693691
| 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
697695
| Policy functions expression string length | 81920 | Example: the length of `"[function(....)]"` |
698696
| `Field count` expressions per array | 5 | |
699697
| `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` expressions also include the iteration count of the parent expression. |
701699

702700
### Limits enforced during evaluation
703701

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:
705703

706704
```json
707705
{
@@ -719,7 +717,7 @@ The length of the string created by the `concat()` function depends on the value
719717
| Number of nodes of complex objects provided as a parameter to, or returned by a function | 32768 | `[concat(field('largeArray1'), field('largeArray2'))]` |
720718

721719
> [!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.
723721
> When writing policies with complex functions, be mindful of these limits and test your policies against resources that have the potential to exceed them.
724722
725723
## Next steps

0 commit comments

Comments
 (0)