[英]Azure Function Triggered by IoT Hub event - the messaging entity could not be found
[英]IoT Hub to Azure Function - The listener for function was unable to start Azure.Messaging.EventHubs could not be found
按照将Azure Function 链接到 IoT 中心消息接收的指南,我收到错误消息:
[2022-07-28T23:11:20.651Z] The listener for function 'DataFromDevice' was unable to start.
System.Private.CoreLib: One or more errors occurred. (The messaging entity
'sb://iothub-ns-mynamespace.servicebus.windows.net/messages/events' could not be found.
To know more visit https://aka.ms/sbResourceMgrExceptions. (messages/events)).
我根据指南从IoT Hub -> Built-in endpoints -> Event Hub compatible endpoint
提取了连接字符串,但是我不得不在最后删除EntityPath
。
否则我的代码编译并上传OK(上面提到了运行时错误),代码如下:
using IoTHubTrigger = Microsoft.Azure.WebJobs.EventHubTriggerAttribute;
using Microsoft.Azure.WebJobs;
using Azure.Messaging.EventHubs;
using System.Text;
using System.Net.Http;
using Microsoft.Extensions.Logging;
public class DataFromDevice
{
private static HttpClient client = new HttpClient();
[FunctionName("DataFromDevice")]
public void Run([IoTHubTrigger("messages/events", Connection = "IoTHubConnectionString")]EventData message, ILogger log)
{
log.LogInformation($"C# IoT Hub trigger function processed a message: {Encoding.UTF8.GetString(message.Body.Span)}");
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.