メッセージを送信して反応できるように、nodeJSでAzure関数を使用してSignalRサービスを実行しようとしています。文書
実際には、バックエンド サービス (SignalR + メッセージ送信機能) をローカルでセットアップしたいだけです。
そのために、SignalR 関数を作成しました。
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"
}
]
}
次に、SignalR サービスにメッセージを送信する 2 番目の関数で:
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": "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;"
}
]
}
その後私はlocal.setting.json
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "node",
"AzureSignalRConnectionString": "Endpoint=https://xxxxxx.service.signalr.net;AccessKey=xxxxxxxxx;Version=1.0;"
},
"Host": {
"LocalHttpPort": 7072,
"CORS": "*"
}
}
SignalR Service の設定にも設定service mode
しています。serverless
今、関数sendmessages
をトリガーする必要があるブラウザで関数を実行して、それをテストしようとしていますsignalR
しかし、sendMessages
ブラウザで関数を実行すると、SignalR Serice function
トリガーされず、context.bindings のみが含まれますreq
( nores
と にsendMessages
リストされていますfunction.json
)
構成に何か不足していますか?