Javascript 正在运行Azure功能不工作的信号器服务
我正在尝试使用azure函数和NodeJ运行SignalR服务,以便能够发送消息进行响应 实际上,我只想在本地设置后端服务(信号器+发送消息功能) 为此,我创建了信号器功能:Javascript 正在运行Azure功能不工作的信号器服务,javascript,signalr,azure-functions,signalr-hub,signalr-2,Javascript,Signalr,Azure Functions,Signalr Hub,Signalr 2,我正在尝试使用azure函数和NodeJ运行SignalR服务,以便能够发送消息进行响应 实际上,我只想在本地设置后端服务(信号器+发送消息功能) 为此,我创建了信号器功能: module.exports = async function (context, req, connectionInfo) { console.log(connectionInfo) context.res.body = connectionInfo; }; 在function.json中 {
module.exports = async function (context, req, connectionInfo) {
console.log(connectionInfo)
context.res.body = connectionInfo;
};
在function.json中
{
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "request",
"methods": [
"get",
"post"
]
},
{
"type": "http",
"direction": "out",
"name": "res"
},
{
"type": "signalR",
"name": "signalRMessages",
"connectionStringSetting": "Endpoint=https://xxxx.service.signalr.net;AccessKey=XXXXXXx;Version=1.0;",
"hubName": "XXXXX",
"direction": "out"
}
]
}
{
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"get",
"post"
]
},
{
"type": "http",
"direction": "out",
"name": "res"
},
{
"type": "signalRConnectionInfo",
"name": "connectionInfo",
"hubName": "xxxxxx", <== here I putted the SignalR service name without the domaine
"direction": "in",
"connectionStringSetting": "Endpoint=https://XXXXX.service.signalr.net;AccessKey=XXXXXX;Version=1.0;"
}
]
}
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "node",
"AzureSignalRConnectionString": "Endpoint=https://xxxxxx.service.signalr.net;AccessKey=xxxxxxxxx;Version=1.0;"
},
"Host": {
"LocalHttpPort": 7072,
"CORS": "*"
}
}
然后在我的第二个功能中,它将向信号机服务发送消息:
module.exports = async function (context, req) {
context.log('JavaScript HTTP trigger function processed a request.');
const name = (req.query.name || (req.body && req.body.name));
const responseMessage = name
? "Hello, " + name + ". This HTTP triggered function executed successfully."
: "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.";
const updates = [{
target: 'updated',
arguments: [responseMessage]
}];
context.bindings.signalRMessages = updates;
context.done();
}
在function.json中
{
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "request",
"methods": [
"get",
"post"
]
},
{
"type": "http",
"direction": "out",
"name": "res"
},
{
"type": "signalR",
"name": "signalRMessages",
"connectionStringSetting": "Endpoint=https://xxxx.service.signalr.net;AccessKey=XXXXXXx;Version=1.0;",
"hubName": "XXXXX",
"direction": "out"
}
]
}
{
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"get",
"post"
]
},
{
"type": "http",
"direction": "out",
"name": "res"
},
{
"type": "signalRConnectionInfo",
"name": "connectionInfo",
"hubName": "xxxxxx", <== here I putted the SignalR service name without the domaine
"direction": "in",
"connectionStringSetting": "Endpoint=https://XXXXX.service.signalr.net;AccessKey=XXXXXX;Version=1.0;"
}
]
}
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "node",
"AzureSignalRConnectionString": "Endpoint=https://xxxxxx.service.signalr.net;AccessKey=xxxxxxxxx;Version=1.0;"
},
"Host": {
"LocalHttpPort": 7072,
"CORS": "*"
}
}
我还在信号机服务设置中将服务模式
设置为无服务器
现在,我正试图通过在浏览器中运行sendmessages
函数来测试这一点,该函数将触发signal
函数
但是当我在浏览器上运行sendMessages
函数时,signar Serice函数
不会被触发,context.bindings只包含req
(在function.json
中列出了nores
和sendMessages
)
我的配置中是否遗漏了一些内容?我也遇到了很多麻烦。。但就我所见,您的functions.json与示例有很多不同之处。与govertiate.json中的属性类型、名称和方向类似。请调整这些,然后再试一次。我也遇到了很多麻烦。。但就我所见,您的functions.json与示例有很多不同之处。与govertiate.json中的属性类型、名称和方向类似。请调整这些,然后重试。