๐Ÿ” Recipe ยท Entra ID & Identity

Create Dynamic Groups in Entra ID with Location and Group Membership Rules

Combine location-based criteria and group membership using nested dynamic groups

Complexity

Intermediate

Impact

access-management + group-lifecycle + automation + entra-id

Context

Why This Matters

Dynamic groups in Microsoft Entra ID automatically populate membership based on user attributes (city, state, department) or membership in other groups. This recipe addresses a common requirement: combining location-based criteria with group membership in a single logical grouping โ€” for example, "everyone in a specific region plus everyone in a specific team."

A critical Entra ID limitation drives this design: the memberOf attribute cannot be combined with other rules (like user.city or user.state) in a single dynamic membership rule. Attempting to do so returns a DynamicGroupQueryParseError. The workaround is a three-group architecture: two dynamic groups (one per rule type) rolled up under a static parent group using nested group membership.

Run this recipe when you need to create distribution lists, access groups, or notification targets that combine geographic/organizational attributes with explicit team membership.

Expected Outcomes

After completing this recipe you will have:

  • A location-based dynamic security group that auto-populates from user attributes (city, state, country).
  • A memberOf dynamic security group that mirrors the membership of a source team/group.
  • A static parent security group with both dynamic groups nested as members, providing a single handle for the combined population.
  • A reusable architecture pattern for future requests that combine dynamic criteria with group membership.

Risks & Considerations

Known limitations

  • memberOf cannot be combined with other rules โ€” this is why we use 3 groups instead of 1.
  • Nested group transitivity is inconsistent across M365 services. Group-based licensing, some Conditional Access scenarios, and certain Exchange features do not resolve nested group membership. Test your specific use case.
  • Security groups are not mail-enabled. If you need a distribution list for email, create a mail-enabled distribution group or Microsoft 365 group separately โ€” security groups cannot be converted.
  • Licensing: Dynamic membership requires Entra ID P1 or P2 licenses for every user in scope. memberOf dynamic groups are in preview with a tenant limit of 500 groups.

Gotchas

  • Initial population of dynamic groups can take several minutes after creation โ€” don't panic if membership is empty at first.
  • User attributes like city and state are free-text. Your rule must account for variations (e.g., "Vaud" vs "VD").
  • Using contains() in Graph $filter on groups is not supported โ€” use startswith() or eq.
  • The correct memberOf syntax is user.memberOf -any (group.objectId -in ['guid']), not group.id.

Required Permissions

PermissionWhy It's Needed
Group.ReadWrite.AllRequired to create security groups, set dynamic membership rules, and add members to the parent group.
Directory.Read.AllRequired to look up the source group (e.g. ClinBio) and inspect user attributes when designing the membership rule.

The fastest way to get this done โ€” just ask Dex. Copy the prompt below and paste it into your Dex conversation.

For IT Admins

Paste into Dex CoAdmin

Create a dynamic distribution group named {parent_group_name} in Entra ID that combines users from {location} (state or city match) with all members of the {source_group} team. Use the supported nested-group pattern: a dynamic location group, a dynamic memberOf group, and a static parent group containing both.
Try in Dex CoAdmin