gpt4 book ai didi

azure - 函数 'SignalR' 的监听器无法启动。 Azure 函数与信号器绑定(bind)

转载 作者:行者123 更新时间:2023-12-02 07:23:31 26 4
gpt4 key购买 nike

我正在开发一个应用程序,其中 IOT 设备与 Azure IOT 中心连接。其实时数据可以在网页 View 上可见。但是,我遇到了一个错误,我正在尝试将数据 Azure 函数与 SignalR 绑定(bind),但是当我运行该应用程序时,我收到以下错误消息。

函数“SignalR”的监听器无法启动。 Microsoft.Azure.EventHubs.Processor:获取 EventHub PartitionId 列表时遇到错误。 System.Private.CoreLib:链接地址“$management”与任何预期格式都不匹配。

Error Description Image

我已经尝试了一切方法来修复它,但每次都失败了。如果有人能帮助我找到这个问题的解决方案,我将不胜感激。

这是我使用的脚本 link

这是我的SignalR.cs类(class)

 public static class SignalR
{
[FunctionName("SignalR")]
public static async Task Run(
[IoTHubTrigger("messages/events", Connection = "IoTHubTriggerConnection", ConsumerGroup = "$Default")]EventData message,
[SignalR(HubName = "broadcast")]IAsyncCollector<SignalRMessage> signalRMessages,
ILogger log)
{

var deviceData = JsonConvert.DeserializeObject<DeviceData>(Encoding.UTF8.GetString(message.Body.Array));
deviceData.DeviceId = Convert.ToString(message.SystemProperties["iothub-connection-device-id"]);


log.LogInformation($"C# IoT Hub trigger function processed a message: {JsonConvert.SerializeObject(deviceData)}");
await signalRMessages.AddAsync(new SignalRMessage()
{
Target = "notify",
Arguments = new[] { JsonConvert.SerializeObject(deviceData) }
});
}
}

这是我的SignalRConnection.cs

    public static class SignalRConnection
{
[FunctionName("SignalRConnection")]
public static SignalRConnectionInfo Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req,
[SignalRConnectionInfo(HubName = "broadcast")] SignalRConnectionInfo info,
ILogger log) => info;
}

这是我的local.settings.json 文件

    {
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"AzureSignalRConnectionString": "",
"MSDEPLOY_RENAME_LOCKED_FILES": 1,
"IoTHubTriggerConnection": ""
},
"Host": {
"LocalHttpPort": 7071,
"CORS": "*"
}
}

对于 IoTHubTriggerConnection,我使用 iothubjohnsoncontrol 的连接字符串(如下图所示)。

IOT Hub Keys Image

对于 AzureSignalRConnectionString,我使用 signalrjohnsoncontrol 的连接字符串(如下图所示)。

SignalR Keys Image

最佳答案

请检查您是否在此处提供了 EventHub 兼容名称和 EventHub 兼容连接字符串 enter image description here

请尝试使用 EventHub 兼容名称和 IoTHubTriggerConnection 替换消息/事件作为门户中的 EventHub 兼容端点。

这里几乎类似的讨论: https://github.com/Azure/azure-event-hubs-dotnet/issues/103

我有一个类似的用例,可以将物联网数据推送到 Azure 数据浏览器,这就是我的函数的样子 enter image description here

与EventHub兼容的Iot Hub连接字符串 enter image description here

希望这有帮助。

关于azure - 函数 'SignalR' 的监听器无法启动。 Azure 函数与信号器绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60344390/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com