Recommended Configuration for Azure Event Hubs in a Shared Staging/Production Environment

43 views Asked by At

I have two Azure AppService slots -- staging and production -- that are each pulling messages from the same Azure EventHub Instance.

When only one slot is active, everything works as expected. However, if I have both slots active, they seem to compete for the same messages, and the state gets shared between the two slots unpredictably. As a result, staging will have some messages, and production will have others. This leads to unexpected and undesired behavior.

As an example, given messages A, B, and C, what currently appears to happen is:

Staging: A, C
Production: B

What I want is:

Staging: A, B, C
Production: A, B, C

How do I configure Azure Event Hubs to achieve the desired processing? For additional context, I am using .NET/C# and the Azure.Messaging.EventHubs.Processor nuget package.

1

There are 1 answers

1
Peter Bons On BEST ANSWER

So, you are looking for a solution in which both slots process the same messages from an Event Hub? If so, your solution would be to use a different Consumer Group per slot:

[..] It enables multiple consuming applications to read the same streaming data in an event hub independently at their own pace with their offsets. [..]

Take a look at this code example showing how to configure the processor to use a specific consumer group.