Cannot connect to IoT hub with EventProcessorHost in .net Core

Viewed 682

I'm trying to connect to an Azure IoT hub from a .NET Core application using the following tutorial as a guide Get started receiving messages with the Event Processor Host in .NET Standard

However I am getting an error when trying to register the event processor:

MessagingEntityNotFoundException: The messaging entity 'sb://<redacted>.servicebus.windows.net/messages/events' could not be found.

This is the code I am using

private const string EhConnectionString = "Endpoint=sb://<redacted>.servicebus.windows.net/;SharedAccessKeyName=iothubowner;SharedAccessKey=<the shared key>";
private const string EhEntityPath = "messages/events";
private const string StorageContainerName = "<containerName>";
private const string StorageAccountName = "<accountName>";
private const string StorageAccountKey = "<storage key>";

private static readonly string StorageConnectionString = string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1};EndpointSuffix=core.windows.net", StorageAccountName, StorageAccountKey);

public static async Task MainAsync(string[] args)
{
    Console.WriteLine("Registering EventProcessor...");

    var eventProcessorHost = new EventProcessorHost(
          EhEntityPath, 
          PartitionReceiver.DefaultConsumerGroupName, 
          EhConnectionString, 
          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();
}
0 Answers
Related