Windows Azure SQL Database Marketplace
The Adoption Program Insights series describes experiences of Microsoft Services consultants involved in the Windows Azure Technical Adoption Program assisting customers deploy solutions on the Windows Azure platform. This post is by Patrick Butler Monterde and Tom Hollander.
Many custom-developed applications need to send email, whether it is a part of the registration process, a way of notifying users when important events occur or something else. If you're a .NET developer you've probably used classes of the System.Web.Mail namespace to accomplish this. However these classes require access to an SMTP e-mail server to send messages and Windows Azure does not currently provide such a capability. However all is not lost. This two-part series describes some patterns for enabling emailing capabilities for applications deployed to the Windows Azure platform.
Pattern 1: Using a Custom On-premise Email Forwarder Service
This pattern utilizes your existing on premise email server to send email on behalf of a Windows Azure application. This is accomplished by creating a custom on-premise Email Forwarder Service that uses Windows Azure Storage queues and blobs to deliver emails generated in Windows Azure to an on-premise email server. The pattern is divided into two main sections:
For the distribution of emails from Windows Azure to the on premise email servers, we will define a concept of a "work item". A work item is a logical container composed of:
The following diagram shows the pattern's workflow:
This is what happens when an application hosted in Windows Azure needs to send an email message:
To better illustrate the pattern, a sample implementation of the Email Forwarder Service and a Windows Azure application that uses it can be downloaded below as a .zip file. The code sample contains the following projects:
Architectural Considerations
It is important to understand the architectural implications for any solution. Some of the considerations for the custom Email Forwarder Service include:
Serialized email objects that contain large email attachments may pose some performance impact since these needs to be serialized, moved to storage and then retrieved and de-serialized by the Email Forwarder Service. Due to asynchronous nature of this pattern, the Email Forwarder Service checks the Windows Azure Storage Queues periodically for work items. This generated a marginal delay sending the emails to the email server. This must be studied carefully and set as per the individual needs.
Part 2 will be posted here later this week.
Tweet