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

标签 azure signalr azure-functions real-time azure-iot-hub

我正在开发一个应用程序,其中 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/

相关文章:

c# - SignalR 和 UploadFromStreamAsync 在 IIS Express 和 Azure 免费网站中具有不同的行为

java - 如何使用java配置@CosmosDBtrigger?

Azure Web功能: Create binding from http request to inputBlob path

azure - AADLoginForWindows 的 Terraform Azure VM 扩展类型和 type_handler_version 参数值

Azure 云服务文件系统访问

Azure 表存储实体大小限制

azure - Azure Function 上未启用 WEBSITE_RUN_FROM_PACKAGE 警告

c# - 使用 C# 调用 Azure 函数

c# - 将SignalR的ITransportHeartbeat添加到Autofac

azure - 为 SignalR ASP.NET 项目选择正确的项目类型和 Windows Azure 服务