1

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.

enter image description here

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"
    }
  ]
}
Nikhileshwar
  • 1,666
  • 1
  • 11
  • 26

1 Answers1

2

SignalR Service needs a URL to access Function App when you're using SignalR Service trigger binding. enter image description here 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

Doris Lv
  • 3,083
  • 1
  • 5
  • 14
  • Thanks for the detailed explanation. I'll check this and let you know. – Nikhileshwar Mar 05 '21 at 05:42
  • Have you solve your problem? @Error280MonkeyFound – Doris Lv Mar 10 '21 at 01:15
  • Hi, yes I solved my issue by completely removing my azure functions and recreating them. Earlier function app had a runtime error. Something was messed up in that app, as I used both portal and vs code to publish functions. – Nikhileshwar Mar 10 '21 at 04:08