C# 无法使用.net Core中的EventProcessorHost连接到IoT集线器
我正在尝试使用以下教程作为指南,从.NET核心应用程序连接到Azure IoT中心 但是,我在尝试注册事件处理器时出错:C# 无法使用.net Core中的EventProcessorHost连接到IoT集线器,c#,azure,.net-core,azure-iot-hub,C#,Azure,.net Core,Azure Iot Hub,我正在尝试使用以下教程作为指南,从.NET核心应用程序连接到Azure IoT中心 但是,我在尝试注册事件处理器时出错: MessagingEntityNotFoundException: The messaging entity 'sb://<redacted>.servicebus.windows.net/messages/events' could not be found. MessaginEntityNotFoundException:找不到消息实体'sb://.serv
MessagingEntityNotFoundException: The messaging entity 'sb://<redacted>.servicebus.windows.net/messages/events' could not be found.
MessaginEntityNotFoundException:找不到消息实体'sb://.servicebus.windows.net/messages/events'。
这是我正在使用的代码
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();
}
private const string EhConnectionString=“Endpoint=sb://.servicebus.windows.net/;SharedAccessKeyName=iothubowner;SharedAccessKey=”;
private const string EhEntityPath=“messages/events”;
私有常量字符串StorageContainerName=“”;
私有常量字符串StorageAccountName=“”;
私有常量字符串StorageAccountKey=“”;
私有静态只读字符串StorageConnectionString=string.Format(“DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1};EndpointSuffix=core.windows.net”、StorageAccountName、StorageAccountKey);
公共静态异步任务mainsync(字符串[]args)
{
Console.WriteLine(“注册事件处理器…”);
var eventProcessorHost=新的eventProcessorHost(
eEntityPath,
PartitionReceiver.DefaultConsumerGroupName,
eConnectionString,
StorageConnectionString,
存储容器名称);
//注册事件处理器主机并开始接收消息
等待eventProcessorHost.RegisterEventProcessorAsync();
控制台。写入线(“接收。按回车键停止工作。”);
Console.ReadLine();
//处置事件处理器主机
等待eventProcessorHost.UnregisterEventProcessorAsync();
}
您的路径不正确。文档对此有点不清楚,但应该只反映eventhub的名称。(如果名称是events,则仅此而已)是,路径参数中的“Event Hub compatible name”属性。ThanksThanks@JohnHunter-在Microsoft.Azure.EventHubs.EventHubClient.CreateFromConnectionString中添加EntityPath=[Event Hub compatible name]
时也是如此。幸运的是,他们很快就会支持你们,你们能分享最终的解决方案吗?即使我不再收到这个特别的错误,我仍然不明白