signalR(协商函数)的 Azure 函数绑定(bind)错误(500 错误代码)

标签 azure signalr azure-functions azure-function-app

我正在使用 Azure 函数和 signalR 创建实时聊天。它在本地工作得很好,但部署的“协商”功能不起作用。

协商函数(index.js)

module.exports = function (context, req, connectionInfo) {
    context.res = { body: connectionInfo };
    context.done();
}

配置文件(function.json)

{
    "disabled": false,
    "bindings": [
      {
        "authLevel": "anonymous",
        "type": "httpTrigger",
        "direction": "in",
        "name": "req"
      },
      {
        "type": "http",
        "direction": "out",
        "name": "res"
      },
      {
        "type": "signalRConnectionInfo",
        "name": "connectionInfo",
        "hubName": "chat",
        "direction": "in",
        "connectionStringSetting": "AzureSignalRConnectionString"
      }
    ]
  }

AzureSignalRConnectionString 在函数应用属性中设置。 我还尝试使用“connectionString”而不是“connectionStringSetting”,并使用连接字符串而不是“AzureSignalRConnectionString”引用,以及我们这里拥有的所有 4 种可能的组合。

如果我在 Azure 门户中运行该函数,则会收到此错误:

[Error] Executed 'Functions.negotiate' (Failed, Id=0ac24b1f-1ab0-40f5-9680-34db547e1cc9)
Unable to resolve the value for property 'SignalRConnectionInfoAttribute.ConnectionStringSetting'. Make sure the setting exists and has a valid value

最佳答案

您是否在代码中编写了“connectionStringSetting”作为属性名称?如果是这样,您可以尝试将其更改为“ConnectionStringSetting”。你可以引用这个tutorial或我在下面发布的屏幕截图:

enter image description here

关于signalR(协商函数)的 Azure 函数绑定(bind)错误(500 错误代码),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58682737/

相关文章:

c# - Azure 网站 - 502 - Web 服务器在充当网关或代理服务器时收到无效响应

c# - SignalR 客户端默认回退传输

Observable 返回时 Angular 5 组件未更新

powershell - Azure Function - PowerShell,安装 az cmdlet::术语 'az' 未被识别为 cmdlet 的名称

azure - 更新 EKS kubernetes 集群代理池配置文件

c# - 如何删除 Log Analytics 数据收集器 API 创建的自定义日志

JQuery 3 和 SignalR 2.2.0

azure - 无法使用 WEBSITE_MAX_DYNAMIC_APPLICATION_SCALE_OUT 设置扩展 azure 函数实例

c# - 天蓝色函数 : Difference between IWebJobsStartup and FunctionsStartup

c# - Azure Function - "PartitionKey extracted from document doesn' t 与在门户中创建的容器上的 header 中指定的匹配