Skip to content

Commit d787de1

Browse files
committed
[Azure AD groups] tips for more efficient rules
1 parent 1497627 commit d787de1

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
---
2+
title: Create simpler and faster rules for dynamic groups - Azure AD | Microsoft Docs
3+
description: How to optimize your membership rules to automatically populate groups.
4+
services: active-directory
5+
documentationcenter: ''
6+
author: curtand
7+
manager: karenhoran
8+
ms.service: active-directory
9+
ms.subservice: enterprise-users
10+
ms.workload: identity
11+
ms.topic: overview
12+
ms.date: 03/25/2022
13+
ms.author: curtand
14+
ms.reviewer: jordandahl
15+
ms.custom: it-pro
16+
ms.collection: M365-identity-device-management
17+
---
18+
19+
20+
# Create simpler, more efficient rules for dynamic groups In Azure Active Directory
21+
22+
The team for Azure Active Directory (Azure AD) sees a lot of incidents related to dynamic groups and the processing time for their membership rules. This article contains the methods by which our engineering team helps customers to simplify their membership rule, which then improves processing time.
23+
24+
When writing membership rules to determine what users or devices get added to dynamic groups, there are steps you can take to ensure the rules are as efficient as possible. More efficient rules result in better dynamic group processing times.
25+
26+
27+
## Minimize use of MATCH
28+
29+
Minimize the usage of the 'match' operator in rules as much as possible. Instead, explore if it is possible to use the 'contains,' 'startswith,' or ‘-eq’ operators. Considering using other properties that allow you to write rules to select the users you want to be in the group without using the -match operator. For example, if you want a rule for the group for all users whose city is Lagos, then instead of using rules like:
30+
31+
```powershell
32+
user.city -match "ago" or user.city -match ".*?ago.*"
33+
```
34+
35+
It is better to use rules like:
36+
37+
`user.city -contains "ago,"` or
38+
`user.city -startswith "Lag,"` or
39+
best of all, `user.city -eq "Lagos"`
40+
41+
## Use fewer OR operators
42+
43+
In your rule, identify similar sub criteria with the same property equaling various values being linked together with a lot of -or operators. Instead, use the -in operator to group them into a single criterion to make the rule easier to evaluate. For example, instead of having a rule like this:
44+
45+
```powershell
46+
(user.department -eq "Accounts" -and user.city -eq "Lagos") -or
47+
(user.department -eq "Accounts" -and user.city -eq "Ibadan") -or
48+
(user.department -eq "Accounts" -and user.city -eq "Kaduna") -or
49+
(user.department -eq "Accounts" -and user.city -eq "Abuja") -or
50+
(user.department -eq "Accounts" -and user.city -eq "Port Harcourt")
51+
```
52+
53+
It is better to have a rule like this:
54+
55+
```powershell
56+
user.department -eq "Accounts" -and user.city -in ["Lagos", "Ibadan", "Kaduna", "Abuja", "Port Harcourt"]
57+
```
58+
59+
Conversely, identify similar sub criteria with the same property not equaling various values, being linked with a lot of -and operators. Then use the -notin operator to group them into a single criterion to make the rule easier to understand and evaluate. For example, instead of using a rule like this:
60+
61+
```powershell
62+
(user.city -ne "Lagos") -and (user.city -ne "Ibadan") -and (user.city -ne "Kaduna") -and (user.city -ne "Abuja") -and (user.city -ne "Port Harcourt")
63+
```
64+
65+
It is better to use a rule like this:
66+
67+
```powershell
68+
user.city -notin ["Lagos", "Ibadan", "Kaduna", "Abuja", "Port Harcourt"]
69+
```
70+
71+
# Avoid redundant criteria
72+
73+
Ensure that you aren't using redundant criteria in your rule. For example, instead of using a rule like this:
74+
75+
```powershell
76+
user.city -eq "Lagos" or user.city -startswith "Lag"
77+
```
78+
It is better to simply use a rule like this:
79+
80+
```powershell
81+
user.city -startswith "Lag"
82+
```
83+
84+
## Next steps
85+
86+
- [Create a dynamic group](groups-dynamic-membership.md)
87+

0 commit comments

Comments
 (0)