Reputation: 1684
I'm new with azure functions and azure as whole.
I'm using azure functions for interacting with a SignalR service for usage in a xamarin forms app. I borrowed the azure function code from docs.MSDocs on serverless signalR service
Worked well in local (tested the web client provided in the docs, And also a simple console app).
But when the function was moved to azure. Initially I faced CORS error fixed those and then faced 502. Could not debug or find the root cause. After few hours of browsing found that azure itself provides a template for signalR serverless connection.
Used the template, configured the app settings with signalR endpoints (I have set the app setting for AzureSignalRConnectionString
).
Still facing 502 error, . How can I get it to work? Or How do I find out the root cause for the failure.
Negotiate function code:
index.js
module.exports = async function (context, req, connectionInfo) {
context.res.body = connectionInfo;
};
Function.json
{
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"methods": [
"post"
],
"name": "req"
},
{
"type": "http",
"direction": "out",
"name": "res"
},
{
"type": "signalRConnectionInfo",
"name": "connectionInfo",
"hubName": "messaage",
"connectionStringSetting": "AzureSignalRConnectionString",
"direction": "in"
}
]
}
Upvotes: 1
Views: 870
Reputation: 3398
SignalR Service needs a URL to access Function App when you're using SignalR Service trigger binding.
The URL format:
<Function_App_URL>/runtime/webhooks/signalr?code=<API_KEY>
. Explanation: The Function_App_URL
can be found on Function App's Overview page and The API_KEY
is generated by Azure Function. You can get the API_KEY from signalr_extension
in the App keys blade of Function App.
And if you are very new to this, here is a step by step article to follow: https://github.com/aspnet/AzureSignalR-samples/tree/master/samples/BidirectionChat
Upvotes: 2