【问题标题】:Azure Function binding error for signalR (negotiate function) (500 error code)signalR(协商函数)的 Azure 函数绑定错误(500 错误代码)
【发布时间】:2020-02-29 03:19:27
【问题描述】:

我正在使用 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 门户中运行该函数,我会收到以下错误:

[错误] 执行“Functions.negotiate”(失败,Id=0ac24b1f-1ab0-40f5-9680-34db547e1cc9)
无法解析属性“SignalRConnectionInfoAttribute.ConnectionStringSetting”的值。确保设置存在且具有有效值

【问题讨论】:

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


    【解决方案1】:

    已解决(在https://social.msdn.microsoft.com/ 上得到了答复)。 我应该在 FunctionApp/Configuration/Application 设置中添加 AzureSignalRConnectionString 而不是 FunctionApp/Configuration/Application 设置/连接字符串。

    【讨论】:

      【解决方案2】:

      您是否在代码中将“connectionStringSetting”写为属性名称?如果是这样,请您尝试将其更改为“ConnectionStringSetting”。你可以参考这个tutorial或者我下面发的截图:

      【讨论】:

      • 我已经尝试过了,但没有成功,同样的错误。无论如何感谢您的回答
      • 嗨@johnykes,您能否分享更多代码,了解您是如何从函数应用中的应用设置中获取连接字符串的?
      • 当然。在我的函数 -> 配置/应用程序设置中,我添加了值为“Endpoint=myappsignalr.service.signalr.net;AccessKey=myaccesskey;Version=…;”的“AzureSignalRConnectionString”连接字符串(但显然具有真实价值)。我应该做一些额外的事情吗?如果你想检查,我可以给你读者访问权限。
      • @johnykes 看来配置没问题。对于这个问题,我认为您可以通过关注此link 在 Azure 门户上提出支持请求。支持团队可以看到您的功能的背景数据并帮助您。
      • 是的,我在 CDN 前几天也遇到了一些问题。也许我的项目有问题。我会尝试支持。
      猜你喜欢
      • 1970-01-01
      • 2020-05-28
      • 2020-03-11
      • 1970-01-01
      • 2016-06-05
      • 1970-01-01
      • 2016-03-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多