|
| 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/29/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 numerous 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 rules. Simpler and more efficient rules result in better dynamic group processing times. When writing membership rules for dynamic groups, these are steps you can take to ensure the rules are as efficient as possible. |
| 23 | + |
| 24 | + |
| 25 | +## Minimize use of MATCH |
| 26 | + |
| 27 | +Minimize the usage of the 'match' operator in rules as much as possible. Instead, explore if it's 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: |
| 28 | + |
| 29 | +- `user.city -match "ago"` |
| 30 | +- `user.city -match ".*?ago.*"` |
| 31 | + |
| 32 | +It's better to use rules like: |
| 33 | + |
| 34 | +- `user.city -contains "ago,"` |
| 35 | +- `user.city -startswith "Lag,"` |
| 36 | + |
| 37 | +Or, best of all: |
| 38 | + |
| 39 | +- `user.city -eq "Lagos"` |
| 40 | + |
| 41 | +## Use fewer OR operators |
| 42 | + |
| 43 | +In your rule, identify when it uses various values for the same property linked together with `-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 | +``` |
| 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's better to have a rule like this: |
| 54 | + |
| 55 | +- `user.department -eq "Accounts" -and user.city -in ["Lagos", "Ibadan", "Kaduna", "Abuja", "Port Harcourt"]` |
| 56 | + |
| 57 | + |
| 58 | +Conversely, identify similar sub criteria with the same property not equal to various values, that are linked with `-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: |
| 59 | + |
| 60 | +- `(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")` |
| 61 | + |
| 62 | +It's better to use a rule like this: |
| 63 | + |
| 64 | +- `user.city -notin ["Lagos", "Ibadan", "Kaduna", "Abuja", "Port Harcourt"]` |
| 65 | + |
| 66 | +## Avoid redundant criteria |
| 67 | + |
| 68 | +Ensure that you aren't using redundant criteria in your rule. For example, instead of using a rule like this: |
| 69 | + |
| 70 | +- `user.city -eq "Lagos" or user.city -startswith "Lag"` |
| 71 | + |
| 72 | +It's better to use a rule like this: |
| 73 | + |
| 74 | +- `user.city -startswith "Lag"` |
| 75 | + |
| 76 | + |
| 77 | +## Next steps |
| 78 | + |
| 79 | +- [Create a dynamic group](groups-dynamic-membership.md) |
| 80 | + |
0 commit comments