What is the replacement for Microsoft.Azure.WebHosts.JobHostConfiguration

Viewed 2338

Trying to follow @matthoneycutt 's tutorial on Azure IoT Hub it seems like Microsoft.Azure.WebHosts.JobHostConfiguration vanished between 3.0.0-beta5 and 3.0.0-rc1 releases of Microsoft.Azure.WebHosts.Host in the Microsoft.Azure.WebHosts nuget package?

What would be the approach to get this code up running in Microsoft.Azure.WebHosts 3.0.0-rc1?

var processorHost = new EventProcessorHost(hubName, consumerGroupName, iotHubConnectionString, storageConnectionString,storageContainerName);
processorHost.RegisterEventProcessorAsync<LoggingEventProcessor>().Wait();
var eventHubConfig = new EventHubConfiguration();
eventHubConfig.AddEventProcessorHost(hubName, processorHost);
var configuration = new JobHostConfiguration(storageConnectionString);
configuration.UseEventHub(eventHubConfig);
var host = new JobHost(configuration);
host.RunAndBlock();

Seems related to this post, though in a different context

1 Answers

You should be able to do that thru the AddEventHubs extension methods (available in Microsoft.Azure.WebJobs.Extensions.EventHubs package)

var builder = new HostBuilder()
            .ConfigureWebJobs(b =>
            {
                b.AddAzureStorageCoreServices()
                .AddAzureStorage()
                .AddEventHubs(eventHubOptions => {
                    var hubName = "hubName";
                    var iotHubConnectionString = "iotHubConnectionString";
                    var storageContainerName = "storageContainerName";
                    var storageConnectionString = "storageConnectionString";
                    var consumerGroupName = "consumerGroupName";

                    var processorHost = new EventProcessorHost(hubName, consumerGroupName, iotHubConnectionString, storageConnectionString, storageContainerName);
                    eventHubOptions.AddEventProcessorHost("eventHubName", processorHost);
                })
Related