Serverless Notifications Using Azure Functions + Twilio + SendGrid
The solution implements a serverless notification framework. Azure functions are used to archive the serverless architecture. Twilio and sendgrid are used as the notification providers. Azure storages tables are used to store the application configurations. Azure Queue storage was used for internal communication of the functions. One single POST
endpoint was provided to send out the notifications HINT: /api/notifications
.
High-level architecture diagram
What's included:
- Prototype of a serverless notification framework
- Uses
Azure Functions
to implement serverless architecture - Uses
Queue Storage
to implement queue architecture - Uses
Table Storage
to store configurations - Uses
Twilio
to send out SMS - Uses
SendGrid
to send out Emails
Table of Content
Quick Start
After setting up your local DEV environment, you can clone this repository and run the solution. Make sure to configure the local.settings.json
with the provided setting values. If you are using a Azure storage account replace AzureWebJobsStorage
value with storage account connection string.
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet"
}
}
Prerequisites
You'll need the following tools:
- Azure Storage Emulator
- Azure Storage Explorer
- .NET, version
>=5
- Visual Studio, version
>=2019
- Twilio Trial Account
- SendGrid Trial Account
Development Environment Setup
First clone this repository locally.
- Install all of the the prerequisite tools mentioned above.
- Connect your Azure storage account into Azure storage explore
link
Or use default emulator storage account. - Create
Configurations
table in table storage - Add below Table storage configurations to the created table
Build and run from source
With Visual studio: Open up the solutions using Visual studio.
- Restore solution
nuget
packages. - Rebuild solution once.
- Run the solution.
- POST
Endpoint
Sample SMS notification request
{
"body": "{\"Id\":\"ed32ef8d-1b19-40cc-915b-b8ff1b4d6ff0\",\"FromNumber\":null,\"ToNumber\":\"+NUMBER_WITH_COUNTRY_CODE\",\"MessageBody\":\"Hello there\"}",
"notificationType": 1,
"isScheduled": false,
"scheduledDateTime": "2021-04-30T00:00:00"
}
License
Licensed under the MIT license.