Reputation: 149
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
Upvotes: 3
Views: 1080
Reputation: 27793
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}");
Upvotes: 1
Reputation: 4993
NamespaceManager.CreateConsumerGroupIfNotExistsAsync
(...)
ConsumerGroupDescription realtimeCG = nsMgr.CreateConsumerGroupIfNotExists("PartitionedStream_AKA_EventHub_Name");
Upvotes: 1