Notifications: Email with Logic Apps

Published: Jul 16, 2020 by Isaac Johnson

Love them or hate them, email notifications are a topic nearly every project needs to solve. Having to trigger them from Azure has come up multiple times in the last week which prompted me to ask, how many ways can we trigger notifications?  Is there an easy serverless way to do this from Azure?  

Azure offers a very straightforward way to create a serverless flow based app using Azure Logic Apps.  We’ll create a Logic App and leverage 4 different ways to trigger notifications: Office365, SMTP to Email providers, SendGrid, and lastly API Gateway.


The first step is to login to the Azure Portal and create a Logic App.

Creating Logic App

You can create a Logic App in the Portal:


We will use an HTTP request


We can use a sample payload to generate the schema:


Next put in a payload.  We’ll need a to for the email address:


which will generate the request schema, for instance:

    "type": "object",
    "properties": {
        "to": {
            "type": "string"


Send Grid

First create a sendgrid account if you don’t already have one:


Then create a Single Sender Verification:


After we verify, we’ll want to create an API key:


In the logic apps designer, after “When an HTTP request is received” click “+New Step”.

Next, add SendGrid and choose Send Email (v4):


Use the API key you generated above:


For a quick demo, we will setup just a hello world. But we will pull in the to as passed via HTTP:


When done, click save:



First, get the POST URL from the first step:


This does include the key so you’ll want to protect it. We can use something like PostMan, but i tend to just use plain old curl:

$ curl --header "Content-Type: application/json" --request POST --data '{"to":""}' ''

Note: my first tests failed because for some reason i wrote (not me):


It was blocked, as one might expect.


Let’s change that to my email address and try again.


Using Office365

If you have Office365, you can use that connector which also allows you to look up details from Azure Active Directory.  This is what one of my Logic Apps looks like today in such environment:


You’ll notice i can use O365 to pull information about a users role, such as Given Name and Surname and add that to the email message for a more polished notification.

You can even pull details from O365 graph.



Create an SNS topic. For a demo, I’ll create “NotifyMe” in us-east-1 and add myself as a subscriber:


We can Publish message to test



We could now go through creating a messaging queue (SQS) that could trigger SNS:


But more often, someone else has done the work.  Simply create a new Lambda and choose “Browse serverless”.  Search for “generic-webhook-to-sns” and launch.


Once launched, you will have a reachable API Gateway endpoint to enque to SQS that has a lambda to trigger SNS.  To receive messages, you’ll need to create a subscription to the created topic.

Create subscription to topic:


Confirm the email to subscribe (like any maillist).


We can test with:

$ curl --header "Content-Type: application/json" --request POST --data '{"to":""}'


Back to the Logic App, add an HTTP step and use POST to pass the same values to the API Gateway trigger:


Now when we invoke our Logic Function:

$ curl --header "Content-Type: application/json" --request POST --data '{"to":""}' ''

We should get an email from SendGrid AND from SNS:


If I cared to really use AWS SNS, i would update the lambda to parse out the details and create a nicer body:


SMTP with Gmail, Yahoo and Others

First, you’ll need toallow insecure apps. By Default, Gmail will block curl and you’ll see “invalid logins”:


When it works, the curl locally should send emails:

$ echo hi > test.txt && curl -u -n --ssl-reqd --mail-from "" --mail-rcpt "" --url smtps:// -T test.txt


Next add parameters for our fields


And then add our values.  Like before, we can use “to” from our passed in values:


Now when we test our logic app:

builder@DESKTOP-2SQ9NQM:~$ curl --header "Content-Type: application/json" --request POST --data '{"to":""}' ''

It fails.. Sadly it seems even with insecure apps it wont work.



  "message": "The SMTP server '' requires a secure connection or the client was not authenticated. Ensure you are using SSL connection and check your account's security settings (if you have enabled 2-step verification, try to use App password, otherwise, turn on access for less secure apps).\r\nclientRequestId: d9efe5bc-c03a-4322-8593-65c191717dd8",



But no settings seemed to work for Yahoo either:


Moving to my domain SMTP server worked just fine, however:



Make sure to remove the deployment from CloudFormation in AWS if you tested that path.

You can regenerate the access key (the &sig part of the URL) from Settings/Access Keys in the Logic App:



In addressing the need for a serverless method to trigger notifications out of Azure we looked into Azure Logic Apps.  We explored four common routes: SMTP, O365, SendGrid and using AWS API Gateway, SQS, Lambda and SNS.  In truth, the last of those could operate independent of the Azure Logic App.

Azure Logic Apps offer a quick and easy way to create templated notifications emails as well as leverage the Microsoft Graph to get user details from Office 365 (Exchange).

azure logic-apps getting-started tutorial

Have something to add? Feedback? Try our new forums

Isaac Johnson

Isaac Johnson

Cloud Solutions Architect

Isaac is a CSA and DevOps engineer who focuses on cloud migrations and devops processes. He also is a dad to three wonderful daughters (hence the references to Princess King sprinkled throughout the blog).

Theme built by C.S. Rhymes