Serverless notifications with Azure Cosmos DB + Azure Functions + Azure SignalR
This repo contains a reusable solution that creates a complete serverless scenario for a chat application that stores data in Azure Cosmos DB, Azure Functions for hosting and event processing and Azure SignalR for websocket client messaging.
To achieve complete serverless, this solution is using:
The solution will provision one Azure Function App with multiple Functions.
In order to support custom routes (particularly for the static Web host), it implements Azure Functions Proxies through a proxies.json file. So when browsing the base URL, it is instead calling one of the HTTP triggered Functions.
It will then negotiate with Azure SignalR the best transport protocol.
When the user writes a message, it will save it to Azure Cosmos DB via an Ajax call to SaveChat
Each chat line is stored as a Document in Azure Cosmos DB.
The FeedToSignalR will trigger and broadcast it to all Azure SignalR connected clients.
This solution does not create any server instance on your subscription, it runs completely on Azure Function’s Consumption Plan and consumes Azure Cosmos DB as a serverless database and Azure SignalR as a serverless websocket notification service.
Clone this repo, fill out the local.settings.json file with the Connection Strings for Azure Cosmos DB and Azure SignalR and run it with F5!
Open your browser in the base address informed by the Azure Function’s runtime (something along the lines of http://localhost:<some-port>
).
Just click in the Deploy to Azure button and it will guide you into automatically creating the Azure Function app with all the code deployed on Azure.
Open your browser in the base address informed by the Azure Function’s Portal (something along the lines of https://<your-app-name>.azurewebsites.net
).