Blog Post

Azure Architecture Blog
8 MIN READ

From Inbox to Event Stream: Scalable Email Processing Pipeline with Microsoft Graph and Azure

jhakanahaiya's avatar
jhakanahaiya
Icon for Microsoft rankMicrosoft
Nov 30, 2026

Processing incoming email sounds simple until volume, shared mailboxes, and downstream business decisions enter the picture.

We recently explored an event-driven approach to enterprise email processing using Microsoft Graph change notifications, Azure Event Hubs, and Azure Container Apps.

The scenario involved approximately seven shared mailboxes receiving around 30,000 emails, while only a small number, roughly 50–60 based on the initial estimate, might ultimately require business action.

But there was an important catch: we couldn't simply treat replies, forwards, or messages in an existing conversation as duplicates. A new message in the same conversation could still contain new instructions, attachments, or other actionable information.

In some cases, we therefore still need the complete email before deciding what happens next.

That led to the real architecture question:

How do we move from mailbox events to full-content processing without making Microsoft Graph the bottleneck?

Moving away from mailbox polling

A straightforward implementation could periodically query each mailbox for new messages.

For this scenario, we explored a different approach: let Microsoft Graph tell us when something changes.

Microsoft Graph supports change notifications for Outlook messages. Instead of repeatedly checking seven mailboxes, the application creates subscriptions for the required mailbox resources.

For shared or delegated mailboxes, Microsoft documents using the appropriate application permission to subscribe to mailbox resources.

Our resulting flow was:

Shared Mailboxes → Microsoft Graph Change Notification → Azure Event Hubs → Azure Container App → Microsoft Graph GET → Downstream Processing

This separates two responsibilities that are easy to mix together:

  • Notification: Something has arrived.
  • Retrieval: Give me the email content I need to process.

That separation is useful because those two operations do not have to happen at exactly the same rate.

 

Figure 1: Mailbox Events Processor
Why Event Hubs matters

In this design, Event Hubs is not simply moving a notification from Graph to another Azure service.

It also creates a buffer between how quickly emails arrive and how quickly the application needs to retrieve and process them.

Consider a burst of emails arriving in one mailbox. We don't necessarily want every new Container App instance immediately making parallel requests to Microsoft Graph.

Instead:

Email burst → Event Hub buffer → controlled consumers → Microsoft Graph

The application can consume the events at a rate appropriate for the downstream dependency.

This became one of the key architectural takeaways from the exploration: Scaling the compute layer doesn't mean every downstream dependency should be called at the same scale.

What about Microsoft Graph throttling?

This was an important consideration before validating the design.

Microsoft documents Outlook service limits per app ID and mailbox combination.

For Outlook APIs, the documented limits include:

  • 10,000 API requests within 10 minutes
  • Four concurrent requests

An important detail is that exceeding the limit for one mailbox does not prevent the same application from accessing another mailbox.

This means the architecture shouldn't look only at the overall daily email count.

For example, if 30,000 messages are distributed across seven mailboxes over a day, the average request volume is very different from 30,000 requests hitting a single mailbox at once.

The bigger design consideration is therefore the burst rate per mailbox.

Protecting Graph from our own scaling

Container Apps can scale consumers based on workload, but unrestricted scaling should not translate directly into unrestricted Graph calls.

The worker therefore needs application-level controls around Graph access.

At minimum, we should include:

  • Per-mailbox concurrency control
  • Idempotent message processing
  • Event-processing checkpoints
  • Controlled retry handling

Microsoft Graph returns HTTP 429 – Too Many Requests when a request is throttled.

When a Retry-After header is returned, Microsoft recommends waiting for that duration before retrying instead of immediately submitting the request again.

In other words, throttling should be designed for rather than treated as an unexpected failure.

Why not process everything from the notification itself?

Microsoft Graph also supports notifications containing selected resource data. For Outlook messages, $select can be used to include selected message properties in the encrypted notification payload.

That can be useful when metadata is sufficient for the next decision.

However, Outlook rich notifications do not allow Body or UniqueBody to be selected.

That matters for our scenario.

A forwarded message or a reply in an existing conversation does not automatically mean "already processed." It may contain new actionable information.

Where the decision depends on the actual content, retrieving the message remains part of the processing flow.

So rather than optimizing Graph calls prematurely, our design treats notification data as a useful first signal and retrieves full content where the business decision requires it.

Architecture
Figure1: What Happens

A production implementation should also maintain the relationship between the Graph subscription and its mailbox so an incoming notification can be routed and processed against the correct mailbox without needing an extra discovery call.

Figure 2: How the architecture is engineered
Enterprise networking: where should the public boundary be?

For an enterprise deployment, authentication alone is usually not the complete security conversation. We also need to understand which components require external connectivity and which communication paths can remain private.

This architecture has two distinct network paths.

Microsoft Graph → Event Hubs

Microsoft Graph supports delivering change notifications directly through Azure Event Hubs. Microsoft specifically positions Event Hubs as an alternative when applications have high-throughput requirements or when the receiving application cannot expose a publicly available notification URL.

This is important because our Container App does not need a public webhook endpoint for Graph notifications.

For authentication, Microsoft currently recommends Microsoft Entra ID and RBAC rather than Shared Access Signatures (SAS). The Microsoft Graph Change Tracking service can be assigned the Azure Event Hubs Data Sender role on the Event Hub.

However, network restrictions on the Event Hubs namespace need to be designed carefully. Restricting the Event Hubs namespace to private access can also prevent other Azure and Microsoft services from reaching it. Microsoft documents trusted-service exceptions for scenarios where selected Microsoft services must continue accessing a network-restricted Event Hub.

For this reason, the ingress path from Microsoft Graph should be validated as part of the organization's networking and security design rather than assuming that disabling all public access will automatically work.

Event Hubs → Container App

The downstream path can be treated differently.

The Container Apps environment can be integrated with an Azure Virtual Network, and Azure Container Apps supports private endpoints for inbound connectivity.

Azure Event Hubs also supports Azure Private Link.

This allows the application side of the architecture to be designed around private network connectivity where required by enterprise policy.

Conceptually:

Microsoft Graph

↓ change notification

Event Hubs controlled ingress boundary

↓ private application-side connectivity

V Net-integrated Container Apps

↓ outbound HTTPS

Microsoft Graph API

The key principle is: Don't apply the same network rule blindly to every stage of an event-driven architecture.

The externally initiated notification path and the private application-processing path have different connectivity requirements.

That distinction became an important part of the PoC because a solution can be fully authenticated and still fail if the network policy prevents the service that produces the event from reaching the messaging layer.

Enterprise security baseline

For an enterprise implementation, I would evaluate the architecture against a small set of controls:

  • Identity: Prefer Microsoft Entra ID and RBAC over long-lived shared secrets where supported.
  • Event Hub ingress: Restrict network access according to organizational policy while preserving the connectivity required for Microsoft Graph notification delivery.
  • Application network: Integrate the Container Apps environment with the enterprise VNet where private backend connectivity is required.
  • Private connectivity: Use Private Link/private endpoints for supported application-side Azure service communication where appropriate.
  • Graph access: Allow only the outbound HTTPS connectivity required for the worker to retrieve messages from Microsoft Graph.
  • Least privilege: Grant the application only the Microsoft Graph and Azure permissions required for its responsibilities.
  • Secrets: Avoid embedding credentials or connection strings in application configuration when identity-based authentication is available.
  • Observability: Monitor Graph 429 responses, Event Hub backlog, consumer failures, subscription expiration, and unusual processing patterns.

This is an important distinction between a functional PoC and an enterprise-ready design. The production architecture must additionally establish the required identity, network, security, resiliency, and operational boundaries.

How to set it up

At a high level, the architecture comes together through a few core building blocks

  1. Configure Microsoft Graph access

Register the application identity and grant the Graph permissions required for Outlook message access.

For subscriptions targeting shared or delegated mailbox resources, use the corresponding application permission supported by Microsoft Graph.

Keep permissions scoped according to the security requirements of the solution.

  1. Create the Event Hubs namespace and Event Hub

Provision the Event Hubs infrastructure that will receive the Graph change notifications.

Treat Event Hubs as both the event-ingestion layer and the buffer between incoming notifications and email retrieval.

  1. Create Graph subscriptions

Create one subscription for each mailbox resource that needs monitoring.

Subscribe only to the change types needed by the solution, such as creation of new messages.

Persist at least the association between:

Mailbox ↔ Mailbox identifier ↔ Graph subscription identifier

Subscriptions are not permanent. Their expiration must be tracked and they need to be renewed before they expire.

  1. Consume events from the Container App

Configure the Container App worker to consume the Event Hub stream.

On receipt of an event:

  1. Identify the Graph subscription.
  2. Resolve the corresponding mailbox.
  3. Check whether the event/message has already been processed.
  4. Retrieve the required message from Microsoft Graph.
  5. Continue with email and attachment processing.
  6. Persist processing state before completing the event.
  1. Add Graph resiliency controls

Do not allow Container App scaling to create uncontrolled Graph concurrency.
Implement:

  • Per-mailbox concurrency limits
  • 429 detection
  • Retry-After handling
  • Safe retries
  • Idempotent processing

This keeps the application scalable while respecting the limits of the service it depends on.

What we learned from validating the design

The most valuable outcome wasn't simply proving that an email notification could travel from Microsoft Graph through Event Hubs to a Container App.

It was understanding where the architectural boundaries should sit.

Graph notifications tell us something happened.

Event Hubs decouples arrival from processing.

Container Apps provides scalable processing capacity.

Microsoft Graph remains a controlled dependency for retrieving the information required to make the actual business decision.

And perhaps most importantly, technical duplication and business duplication aren't always the same thing.

The same event should not be processed repeatedly. But a new reply or forwarded message within an existing conversation may contain new information and shouldn't automatically be discarded simply because we've already seen that conversation.

That distinction becomes increasingly important when downstream processing needs reliable, complete information before making a decision.

Final takeaway

Event-driven architecture isn't just about replacing polling with notifications.

The real value is being able to decouple the rate at which events occur from the rate at which downstream services need to process them.

For this architecture, that leads to a straightforward pattern:

Microsoft Graph → Event Hubs → Azure Container Apps → controlled Graph retrieval → downstream processing

The components themselves aren't the difficult part.

The important architectural decisions are where to buffer, where to control concurrency, how to recover from throttling, how to establish the right network boundaries, and when you have enough information to make a reliable business decision.

Getting those boundaries right is what turns a working integration into a design that can evolve toward production.

Published Nov 25, 2026
Version 1.0
No CommentsBe the first to comment