Does anyone know how to query and create consumer groups in Azure Event Hubs using the .NET SDK. I've googled loads and can only find a way through the REST API (which I can do, but it would nicer if I can do it through the SDK). Thanks in advance
Does anyone know how to query and create consumer groups in Azure Event Hubs using the .NET SDK.
You could try to install this NuGet package, and as Sreeram said, we could use the NamespaceManager class to create consumer group.
var manager = NamespaceManager.CreateFromConnectionString("{your connection string}");
manager.CreateConsumerGroupIfNotExists("{eventHubPath}", "{consumergroup Name}");
After you executed the code, you will find the consumer group is created.

To get the consumer group, you could try to call EventHubClient.GetConsumerGroup method.
var factory = MessagingFactory.CreateFromConnectionString("{your connection string}");
var client = factory.CreateEventHubClient("{eventHubPath}");
EventHubConsumerGroup group = client.GetConsumerGroup("{consumergroup Name}");
NamespaceManager.CreateConsumerGroupIfNotExistsAsync(...)
ConsumerGroupDescription realtimeCG = nsMgr.CreateConsumerGroupIfNotExists("PartitionedStream_AKA_EventHub_Name");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With