Azure SignalR Javascript协商“无法解析…ConnectionStringSetting”

问题描述 投票:0回答:1

我开始修补Azure SignalR,但遇到了带有negiotate触发器的问题。我遵循了this官方Microsoft指南:

这里输入我的代码:

local.settings.json

{
  "IsEncrypted": false,
  "Values": {
    "AzureSignalRConnectionString": "Endpoint=https://my.service.signalr.net;AccessKey=myKey=;Version=1.0;",
    "FUNCTIONS_WORKER_RUNTIME": "node"
  },
  "Host": {
    "LocalHttpPort": 7071,
    "CORS": "*",
    "CORSCredentials": true
  }
}

function.json

{
  "disabled": false,
  "bindings": [
    {
      "authLevel": "anonymous",
      "type": "httpTrigger",
      "direction": "in",
      "methods": [
        "get"
      ],
      "name": "req",
      "route": "negotiate"
    },
    {
      "type": "http",
      "direction": "out",
      "name": "res"
    },
    {
      "type": "SignalRConnectionInfo",
      "name": "connectionInfo",
      "hubName": "jitsi",
      "ConnectionStringSetting": "Endpoint=https://my.service.signalr.net;AccessKey=myKey;Version=1.0;",
      "direction": "in"
    }
  ]
}

index.js

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

它在本地运行良好(不幸的是,指南结束了)。但是,如果我访问协商http-trigger的URL,则会收到“内部服务器错误500”。日志包含以下输出。

2020-04-23T08:47:32  Welcome, you are now connected to log-streaming service. The default timeout is 2 hours. Change the timeout with the App Setting SCM_LOGSTREAM_TIMEOUT (in seconds). 
2020-04-23T08:47:52.070 [Information] Executing 'Functions.jitsiNegotiate' (Reason='This function was programmatically called via the host APIs.', Id=2b791d95-3775-47bb-ade1-ac9005929f61)
2020-04-23T08:47:52.238 [Error] Executed 'Functions.jitsiNegotiate' (Failed, Id=2b791d95-3775-47bb-ade1-ac9005929f61)
Unable to resolve the value for property 'SignalRConnectionInfoAttribute.ConnectionStringSetting'. Make sure the setting exists and has a valid value.

您可以在我的代码中看到,我确实提供了ConnectionStringSetting

有人建议,这是由于ConnectionStringSetting中的大小写为'C'。据说其他人要编辑local.settings.json。这些都对我没有影响,我找不到有关此问题的任何有用信息。

编辑1:我设定为"hubName":"jitsi"jitsi是我的SignalR服务的名称。如在“ jitsi.service.signalr.net”中。我不确定这是否正确。也许那是问题的一部分?

编辑2:我尝试没有为ConnectionStringSetting设置任何值(以便将其设置为默认值)。给了我同样的错误。我还完全删除了local.settings.json的所有内容,然后重新部署以查看会发生什么。与以前相同的行为。我的猜测是,该服务仅将文件用于本地使用(因此命名)。因此,在local.settings.json为空的情况下,没有其他地方可以定义AzureSignalRConnectionString的值。我做了一些挖掘,显然(根据this线程),您应该在[]下定义它

'配置'->'应用程序设置'

所以我用]创建了一个新设置>

名称:Azure__SignalR__ConnectionString

值:myMaskedConnectionString

导致以下错误:

The SignalR Service connection string must be set either via an 'AzureSignalRConnectionString' app setting, via an 'AzureSignalRConnectionString' environment variable, or directly in code via SignalROptions.ConnectionString or SignalRConnectionInfoAttribute.ConnectionStringSetting.

我开始修补Azure SignalR,但遇到了带有negiotate触发器的问题。我遵循了这份官方的Microsoft指南:这是我的代码:local.settings.json {“ IsEncrypted”:false,“ ...

azure signalr azure-function-app azure-signalr
1个回答
0
投票

我找到了解决此问题的方法:

起初我很困惑,以为local.settings.json将用作功能的实时/非本地版本的配置。事实并非如此。它仅用于本地执行(可以通过文件名猜测)

© www.soinside.com 2019 - 2024. All rights reserved.