An Azure event routing service designed for high availability, consistent performance, and dynamic scale.
With Microsoft Entra ID (JWT) authentication for Event Grid MQTT, client attributes are not taken from the app registration or Azure AD object. Instead, they come from either:
- Claims in a custom OAuth 2.0 JWT (non‑Entra ID), or
- Attributes returned by a custom webhook authenticator.
With pure Entra ID + Azure RBAC (EventGrid TopicSpaces Publisher/Subscriber roles), there is no built‑in way to attach arbitrary attributes like enterprise or site to the client identity and have them appear as client.attributes.* for topic templates.
To re‑create the behavior used with certificate‑based clients (for example, ${client.attributes.enterprise}/${client.attributes.site}/+/+), use one of the flexible authentication options instead of (or in addition to) Entra ID RBAC:
Option 1: OAuth 2.0 JWT with custom claims
- Configure OAuth 2.0 JWT authentication on the Event Grid namespace (Key Vault or direct upload of public keys).
- Have the identity provider issue JWTs that include claims such as
enterpriseandsitewith supported types:-
string -
int32 -
array of strings
-
- Event Grid maps all non‑standard claims of these types to client attributes. For example, a token like:
results in:{ "iss": "https://idp.example.com/", "sub": "client-123", "aud": ["<namespace-hostname>", "other-audience"], "exp": 1735689600, "nbf": 1735686000, "enterprise": "contoso", "site": "plant-01" }-
client.attributes.enterprise = "contoso" -
client.attributes.site = "plant-01"
-
- Topic templates can then safely use:
-
${client.attributes.enterprise}/${client.attributes.site}/+/+
-
Key points from the configuration:
- Standard claims
iss,sub,aud,exp,nbfare not mapped to attributes. - All other claims with type
int32,string, orarray of stringsare mapped to client attributes.
Option 2: Custom webhook authentication
If Entra ID must remain the primary identity source, use custom webhook authentication:
- Configure the namespace to use custom webhook authentication.
- When a client connects, Event Grid calls the webhook with connection details (including Entra ID token if used).
- The webhook decides whether to allow the connection and returns:
{ "decision": "allow", "clientAuthenticationName": "client-123", "attributes": { "enterprise": "contoso", "site": "plant-01" }, "expiration": 1735689600 } - The
attributesdictionary is turned into client attributes, again available asclient.attributes.enterpriseandclient.attributes.sitein topic templates and client group queries.
Supported attribute types are the same as for JWT claims: int32, string, array of strings.
Summary for the described scenario
- Entra ID + RBAC alone cannot provide
client.attributes.enterprise/sitefor topic templates. - To enforce per‑enterprise topic isolation via
${client.attributes.*}:- Use OAuth 2.0 JWT authentication and put
enterprise/sitein custom claims, or - Use custom webhook authentication and return
attributesin the webhook response.
- Use OAuth 2.0 JWT authentication and put
This preserves the same pattern used with certificate‑based clients while using token‑based or webhook‑based authentication.
References:
- Microsoft Entra JWT authentication and Azure RBAC authorization to publish or subscribe MQTT messages
- OAuth 2.0 JSON Web Token (JWT) authentication and authorization to publish or subscribe to MQTT messages
- Client authentication
- Overview of the MQTT broker feature in Azure Event Grid
- Use OAuth 2.0 JSON Web Tokens (JWT) to authenticate with namespaces
- MQTT clients
- Authenticate with the MQTT broker by using custom webhook authentication