Is it possible to get Microsoft change notifications in a single API trigger instead of multiple API triggers?

Umair Ahmed 51 Reputation points
2021-11-18T06:42:46.403+00:00

We're using Microsoft change notifications to listen to new emails in a user's mailbox. Right now, for each new email, a separate trigger is sent to our endpoint. We tested by sending 10s of emails within the same second and Microsoft sends a separate hit for each email like this:

{
  "value": [
    {
      "id": "lsgTZMr9KwAAA",
      "subscriptionId":"{subscription_guid}",
      "subscriptionExpirationDateTime":"2016-03-19T22:11:09.952Z",
      "clientState":"secretClientValue",
      "changeType":"created",
      "resource":"users/{user_guid}@{tenant_guid}/messages/{long_id_string}",
      "tenantId": "84bd8158-6d4d-4958-8b9f-9d6445542f95",
      "resourceData":
      {
        "@odata.type":"#Microsoft.Graph.Message",
        "@odata.id":"Users/{user_guid}@{tenant_guid}/Messages/{long_id_string}",
        "@odata.etag":"W/\"CQAAABYAAADkrWGo7bouTKlsgTZMr9KwAAAUWRHf\"",
        "id":"{long_id_string}"
      }
    }
  ]
}

We were expecting that for changes that occur very rapidly, notifications will be grouped together and sent in a single API trigger because if you look, the value key in the above response is an array.

Is it currently possible to somehow specify to Microsoft Notifications to send notifications grouped together instead of a separate API call? The problem is we don't want Microsoft to hit our API endpoint too often to avoid choking of our servers as we'll be subscribing to hundreds of thousands of mailboxes.

Any help in this regard shall be appreciated.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,860 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Barry Gervin 91 Reputation points Microsoft Employee
    2022-02-07T14:47:45.457+00:00

    While there is no batching on change notifications, you may want to also think about using event hub to deliver notifications to an intermediate buffer. https://learn.microsoft.com/en-us/graph/change-notifications-delivery

    If you still need to query from EventHub in batch, a ReceiveAsync method overload allows you to specify a max # of events. https://learn.microsoft.com/en-us/dotnet/api/microsoft.servicebus.messaging.eventhubreceiver.receiveasync?view=azure-dotnet#microsoft-servicebus-messaging-eventhubreceiver-receiveasync(system-int32-system-timespan)

    I hope that helps.

    Barry Gervin
    Microsoft Graph CPx Team

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.