Say I'm working with an Azure SignalR Service run in serverless mode to implement a chat application. I'm wondering why would we use Azure Functions for this. What do they provide us? Couldn't we just build the connection with the SignalR Service on our own directly? Or say, after we negotiate an access token with an Azure Function, why can't we just use the connection we build with that token to broadcast messages, rather than relying on an additional Azure Function to broadcast messages?
1 Answers
In the past, people used to couple SignalR in their own web api or mvc project. The problem was that when there was a need to scale, it wasn't possible to scale things separately. Also, when comes to SignalR, it's hard to work with sticky sessions for example. This is when they released Azure SignalR Service, a managed service that would implement the backplane pattern for you.
More info:
https://learn.microsoft.com/en-us/aspnet/signalr/overview/performance/scaleout-in-signalr
The last piece would be to separate the real time bi-directional communication from the webapi / mvc project. They added Azure Functions as it's a light weight and easier to scale when comparating with webapi / mvc.
why can't we just use the connection we build with that token to broadcast messages, rather than relying on an additional Azure Function to broadcast messages
A: It's because the function is not being executed 100% time.

- 17,332
- 6
- 45
- 90
-
Thank you! "It's because the function is not being executed 100% time." I'm not sure I understand. Could you elaborate a little bit? – Josh Jul 30 '20 at 17:28
-
sure, usually you'll use Functions with Consumption plan. Which means your functions will execute if / when they receive a request only. – Thiago Custodio Jul 30 '20 at 17:58
-
I see... how is that different from if we just skipped the azure function, and used the built signalR connection to broadcast messages directly? Is that even an option? – Josh Jul 30 '20 at 18:42
-
as I said, you'll need to implement the backplane yourself – Thiago Custodio Jul 30 '20 at 18:42
-
and if you don't use functions, you'll have an overkill just to host your hubs – Thiago Custodio Jul 30 '20 at 18:43