public EventHubProducer(EventHubNamespaceConfig config, string hubName) { _config = config; var matchingHub = _config.Hubs.FirstOrDefault(x => x.Name == hubName); if (matchingHub == null) { throw new ArgumentException("Hub Name Not Found"); } _client = EventHubClient.CreateFromConnectionString(matchingHub.GetConnectionString(_config.ConnectionString)); }
public EventHubConsumer(EventHubNamespaceConfig config, string hubName) { _config = config; string storageConnectionString = string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}", _config.StorageAccountName, _config.StorageAccountKey); string eventProcessorHostName = Guid.NewGuid().ToString(); var hub = _config.Hubs.FirstOrDefault(x => x.Name == hubName); if (hub == null) { throw new ArgumentException("Hub Name Not Found"); } _eventProcessorHost = new EventProcessorHost(eventProcessorHostName, hub.Name, EventHubConsumerGroup.DefaultGroupName, _config.ConnectionString, storageConnectionString); }