I am part of a team building a proprietary Learning Management System for our organization. When a user is enrolled into an online course, we are sending an email to the user with instructions on logging in to take their course. When enrolling users en masse, obviously this is causing some performance issues. I am looking into developing a framework for queuing emails and then sending them asynchronously.
Our platform is deployed via an Azure web app and Azure SQL database. It is written in .NET MVC and we are sending emails via SMTP.
Does anyone have any recommendations on best practice or what would be the most effective way to accomplish this? I've looked into Azure Service Bus, third-party open source solutions (such as Hangfire), and writing a standard console application that processes a database table of the emails to be sent.
You are on the right path. Azure Service Bus and Azure Functions will suit your needs. The flow will be:
Azure Service Bus bindings for Azure Functions
Get started with Service Bus queues
If you decide to use Hangfire, it would be optimal to use the Hangfire.Azure.ServiceBusQueue package.
Adds support for using Azure Service Bus Queues with Hangfire's SQL storage provider to reduce latency and remove the need to poll the database for new jobs.
All job data continues to be stored and maintained within SQL storage, but polling is removed in favour of pushing the job ids through the service bus.