Real-time apps with Azure SignalR Service and Azure Functions
Azure SignalR Services combined with Azure Functions allows you to run real-time messaging web apps in a serverless environment. This article provides an overview of how the services work together.
Azure SignalR Service and Azure Functions are both fully managed, highly scalable services that allow you to focus on building applications instead of managing infrastructure. It's common to use the two services together to provide real-time communications in a serverless environment.
Integrate real-time communications with Azure services
- HTTP and webhook requests
- Periodic timers
- Events from Azure services, such as:
- Event Grid
- Event Hubs
- Service Bus
- Azure Cosmos DB change feed
- Storage blobs and queues
- Logic Apps connectors such as Salesforce and SQL Server
By using Azure Functions to integrate these events with Azure SignalR Service, you have the ability to notify thousands of clients whenever events occur.
Some common scenarios for real-time serverless messaging that you can implement with Azure Functions and SignalR Service include:
- Visualize IoT device telemetry on a real-time dashboard or map.
- Update data in an application when documents update in Azure Cosmos DB.
- Send in-app notifications when new orders are created in Salesforce.
SignalR Service bindings for Azure Functions
An example scenario
An example of how to use the SignalR Service bindings is using Azure Functions to integrate with Azure Cosmos DB and SignalR Service to send real-time messages when new events appear on an Azure Cosmos DB change feed.
- A change is made in an Azure Cosmos DB collection.
- The change event is propagated to the Azure Cosmos DB change feed.
- An Azure Functions is triggered by the change event using the Azure Cosmos DB trigger.
- The SignalR Service output binding publishes a message to SignalR Service.
- The SignalR Service publishes the message to all connected clients.
Authentication and users
SignalR Service allows you to broadcast messages to all or a subset of clients, such as those belonging to a single user. You can combine the SignalR Service bindings for Azure Functions with App Service authentication to authenticate users with providers such as Microsoft Entra ID, Facebook, and Twitter. You can then send messages directly to these authenticated users.
For full details on how to use Azure Functions and SignalR Service together visit the following resources:
- Azure Functions development and configuration with SignalR Service
- Enable automatic updates in a web application using Azure Functions and SignalR Service
To try out the SignalR Service bindings for Azure Functions, see: