我尝试使用以下教程作为指南,从.NET Core应用程序连接到Azure IoT中心Get started receiving messages with the Event Processor Host in .NET Standard
但是我在尝试注册事件处理器时遇到错误:
MessagingEntityNotFoundException: The messaging entity 'sb://<redacted>.servicebus.windows.net/messages/events' could not be found.
这是我正在使用的代码
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();
}