How To Send Emails With Azure Twilio SendGrid

Introduction

When designing business logic, we frequently run into situations where an application must email users with information, such as the status of delivery in a shopping application or the progress of a long-running submitted job.

Developers frequently waste a lot of time in these situations trying to structure emails and deliver them via an SMTP server. This entails building email-sending code that will become a component of the program. Any formatting or text changes require a new deployment, and the entire CI CD pipeline must be executed.

However, there is a SAAS Azure solution that can assist with email sending while keeping email templating logic external to the code.

I’ll demonstrate how to create a Twilio SendGrid login using your Azure membership today.

 

Prerequisites

Basic understanding of the Azure interface and an Azure subscription.
Knowing C#,.NET Core, and higher (samples are written in .net core)

 

Steps

1.Login to Azure Portal and Search for TwilioSendgrid

 

2.Twilio has many plans as shown below, but for demo purposes, I’ll select the free plan.

 

3.Select the subscription and resource group.

 

4.Finally review the configurations you have done

 

5.After the resource is created, navigate to the resource and click on “Open SAAS Account on publisher site”

 

6.The above step will take you to app.sendgrid.com, where the account is already logged-in.

The first step here is to create and verify the sender identity

 

There is a step by step guide to achieving this using the documentation provided on the website

7.When finished, you can browse the website. The next step is to create the API Keys that will be used in the application; to do this, click on the user name on the left side.

 

8.Create the API keys as shown below

 

9. Once you have the API Keys this can be used in your application to send Emails

To send emails, utilize the “SendGrid” nugget package, which is available. Using the API keys, sender email ID, and sender name, I have created a short piece of code to send emails.

https://github.com/santoshkaranam/MailWithAzureTwilioSendGrid

 

References

  1. https://docs.sendgrid.com/for-developers/partners/microsoft-azure-2021
  2. https://sendgrid.com/partners/azure/

 

Submit a Comment

Your email address will not be published.

Subscribe

Select Categories