Real-time updates with snapshot of latest values using built-in Azure primitives

73 Views Asked by At

I want to build an Azure app that sends keyed real-time updates to clients.

Required functionality:

  • Ability to expose a REST endpoint that can be used to push key value updates (e.g. key1: value1).
  • Ability to send a snapshot of cumulative latest values of all keys to newly connected clients (e.g. { key1: value1, key2: value2 })

I'm thinking of doing this with Azure SignalR in "Default" (i.e. not "Serverless") mode backed by a custom service hosted by the Azure App service that exposes a REST endpoint for updates and also persists and forwards a snapshot to newly connected clients.

Now I'm wondering: is there any way to accomplish the above using "out-of-the-box" Azure building blocks without having to write and maintain a custom web app? The functionality I'm looking for appears pretty standard for a real-time app, so I'm surprised I'm not able to find an easy way to do this. All the code samples I see online either require a custom web app or don't seem to solve the send-snapshot-of-latest-values-to-new-clients problem at all.

I don't mind switching to a different technology (e.g. Azure Web PubSub) if that would come with what I need out-of-the-box.

1

There are 1 best solutions below

0
PramodValavala On

Azure SignalR (or Web PubSub) provides the base service for you to implement real-time functionality in your apps, but I don't believe there is a codeless way of doing everything end to end.

But you could use features across Azure to implement it in a less code-coding way. This would involve using Azure Functions, specifically Durable Functions.

Here is a high-level flow

  • Azure SignalR (or Web PubSub) for the client push implementation, using Azure Function bindings
  • HTTP Triggered function to update a stateful entity
  • Another function to push latest update to all clients (this could be HTTP Triggered, Queue Triggered, etc. which would be invoked directly/indirectly by the update command)

Note that the above, while involving very little custom code (apart from the entity part), involves queue messages behind the scene due to how Durable Functions work which would add to the latency of updates.