我正在使用 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或我在下面发布的屏幕截图:
关于signalR(协商函数)的 Azure 函数绑定(bind)错误(500 错误代码),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58682737/