I am trying to receive data from Azure Event Hub and display them on .NET core 2.1 Web App using signalR. I have follow this tutorial https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-dotnet-standard-getstarted-receive-eph and everything works on .net core console app. But I have stuck on how to implement this in web app. I am still new in web app so maybe my problem is trivial. Here is main web app code
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>();
And part of code from tutorial which is responsible for deploying event processor is in MainAsync(string[] args)
private static async Task MainAsync(string[] args)
{
Console.WriteLine("Registering EventProcessor...");
var eventProcessorHost = new EventProcessorHost(
EventHubName,
PartitionReceiver.DefaultConsumerGroupName,
EventHubConnectionString,
StorageConnectionString,
StorageContainerName);
// Registers the Event Processor Host and starts receiving messages
await eventProcessorHost.RegisterEventProcessorAsync<SimpleEventProcessor>();
Console.WriteLine("Receiving. Press ENTER to stop worker.");
Console.ReadLine();
// Disposes of the Event Processor Host
await eventProcessorHost.UnregisterEventProcessorAsync();
}
Here is my problem. How to run MainAsync and run web app? If I do something like this
public static void Main(string[] args)
{
MainAsync(args);
CreateWebHostBuilder(args).Build().Run();
}
Everything compiles but nothing happens when there is new event in event hub, and I don't know why and how to solve this problem