4

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();
}
John Hunter
  • 4,042
  • 4
  • 26
  • 35
  • 1
    Your path is incorrect. The docs are a bit unclear about this but it should reflect only the name of your eventhub. (if the name is events then just that) – Peter Bons Nov 28 '17 at 12:37
  • 3
    Yes it is the "Event Hub-compatible name" property that goes in the path parameter. Thanks – John Hunter Nov 28 '17 at 18:30
  • Thanks @JohnHunter - It's the same when you do `Microsoft.Azure.EventHubs.EventHubClient.CreateFromConnectionString` there you need to add `EntityPath=[Event Hub-compatible name]`. Luckily they will soon support [IoT connectionstrings](https://github.com/Azure/azure-event-hubs-dotnet/issues/167) – Søren Høyer Kristensen Dec 07 '17 at 13:12
  • could you guys share the final solution? I still don't get it even tho I no longer receive this particular error – Dmytro Zhluktenko Sep 25 '18 at 21:19

0 Answers0