Create a Logic App that sends an email

Introduction

This project focuses on creating a Logic App that sends an email message automatically on Microsoft Azure. Logic Apps are serverless workflows that make it easy to automate tasks without managing servers.

Why Is It Useful?

Automation: Automatically trigger emails in response to events or at scheduled times.

Scalability: No infrastructure management; pay only for what you use (or free within certain limits).

Integration: Easily connect different services (Office 365, Gmail, or third-party APIs).

Prerequisites

  • Azure Account (Free Tier)
    Sign up at https://azure.microsoft.com/free.
    This can be done without spending any credits if you use the free resources included.
  • Azure CLI Installed
    Download and install from https://docs.microsoft.com/cli/azure/install-azure-cli.
    Ensure it’s updated to the latest version.
  • Azure Subscription Permissions
    Owner
    or Contributor role recommended on the subscription to create resources.
  • Logic Apps Preview or General Availability
    Standard Azure Logic Apps or Consumption-based Logic Apps.
    This guide uses Consumption logic apps so you pay only for each run (and free for minimal usage).
  • Email Provider
    An Office 365 Outlook account, or a Gmail account, or another SMTP provider.
    You will need to authenticate the Logic App with your email service so it can send emails on your behalf.

Step-by-Step Implementation

Below are the steps to create and deploy your Logic App. Each step combines console (GUI) and terminal (CLI) instructions so you can follow whichever method you prefer—or learn both.

Create a Resource Group

A Resource Group is a container in Azure that holds related resources.

In the Console (GUI)

Go to the Azure Portal.

On the left menu, select Resource groups.

Click + Create.

Subscription: Choose your free-tier subscription.

Resource group: For example, MyLogicAppRG.

Region: Pick a region close to you, e.g. East US.

Click Review + create, then Create.

Resource Group details.

In the Terminal (CLI)

Explanation:

  • az login: Authenticates your Azure CLI session.
  • az group create: Creates a new Resource Group.
  • --name MyLogicAppRG: Sets the Resource Group name to MyLogicAppRG.
  • --location eastus: Chooses the Azure region.

Create a Logic App (Consumption) Resource

In the Console (GUI)

In the Azure Portal, click Create a resource (top left).

Search for Logic App.

Select Logic App (Consumption) and click Create.

Basics tab:
Subscription: Your free-tier subscription.
Resource group: Pick MyLogicAppRG.
Name: For example, SendEmailLogicApp.
Region: East US (should match the resource group region ideally).
Plan type: Ensure it’s set to Consumption (pay per execution; free if usage is minimal).

Review + CreateCreate.

In the Terminal (CLI)

Logic Apps can be created with the az resource command or via an ARM template. Below is a simplified approach using the az resource create command:

Explanation:

  • az resource create: Generic command to create an Azure resource.
  • --resource-type "Microsoft.Logic/workflows": Specifies that this is a Logic App resource.
  • --properties '{"state":"Enabled"}': Starts the Logic App in Enabled state (necessary for consumption logic apps).


Define the Logic App Workflow (Trigger and Action)

We’ll set up a trigger (for example, an HTTP trigger or a Recurrence trigger) that prompts the Logic App to send an email. We’ll also configure the Send email action.

In the Console (GUI)

Go to Resource groups → open MyLogicAppRG.

Click on SendEmailLogicApp to open it.

On the Logic App page, click Logic App Designer (or Workflow in some interfaces).

Choose a trigger:
If you want a time-based trigger, click Recurrence and set it to run every X minutes/hours/days.
Or, if you prefer a manual trigger for testing, select When an HTTP request is received.

After selecting the trigger and configuring it, click + New step below it.

Search for Outlook or Gmail or your preferred email connector, e.g. “Office 365 Outlook — Send an email (V2).”

Sign in to your email account if prompted, allowing the Logic App to send emails.

In the Send an email action fields:
To: Your test email address or a distribution list.
Subject: e.g. “Hello from Azure Logic Apps!”
Body: Custom message.

Click Save at the top.

In the Terminal (CLI)


# 1) Create a simple JSON definition for your Logic App workflow:

cat <<EOF > logicapp-workflow.json

{

"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",

"contentVersion": "1.0.0.0",

"resources": [

{

"type": "Microsoft.Logic/workflows",

"apiVersion": "2019-05-01",

"name": "SendEmailLogicApp",

"location": "eastus",

"properties": {

"state": "Enabled",

"definition": {

"triggers": {

"EveryDayTrigger": {

"type": "Recurrence",

"recurrence": {

"frequency": "Day",

"interval": 1

}

}

},

"actions": {

"SendEmail": {

"type": "ApiConnection",

"inputs": {

"host": {

"apiId": "/subscriptions/<subscription_id>/providers/Microsoft.Web/locations/eastus/managedApis/office365"

},

"method": "post",

"path": "/sendmail",

"body": {

"subject": "Hello from Azure Logic Apps!",

"body": "This is a test email.",

"to": [

"your_email@example.com"

]

}

},

"runAfter": {}

}

},

"contentVersion": "1.0.0.0"

}

}

}

]

}

EOF


# 2) Deploy this template to Azure

Explanation:

  • We create a basic ARM template named logicapp-workflow.json describing the trigger and the email action.
  • az deployment group create deploys the template to the resource group.

Verifying and Testing the Project

  • Run Trigger Manually or Wait
    If you used an HTTP trigger, copy its URL from the Trigger block in the Logic App Designer and POST to it (e.g., with curl or Postman).
    If you used a Recurrence trigger, wait until the set schedule hits.
  • Check Logic App Run Status
    In the Azure PortalSendEmailLogicAppRuns history.
    Each run will show Succeeded or Failed.
  • Confirm Email Delivery
    Check your email inbox (the “To” address you specified).
    You should see the email with the Subject and Body you configured.

Common Issues and Troubleshooting

  • Authentication Failed
    Ensure you properly authorized the Logic App to access your email provider (e.g., Office 365 Outlook).
    Re-check credentials or re-sign in through the connector.
  • Resource Permissions
    You might see errors if your user account isn’t an Owner or Contributor. Double-check your Role Assignments in Azure.
  • Trigger Not Firing
    If using Recurrence, verify the interval and frequency.
    If using HTTP, ensure you POST to the correct URL with valid JSON if required.
  • Consumption Plan Billing
    Although it’s generally minimal cost, if you exceed free usage or do frequent triggers, you may incur costs. Monitor usage in Cost Management.
  • Connector Issues
    The Office 365 or Gmail connector might need additional “API connection” resources. Confirm that a corresponding resource named something like office365-connection or gmail-connection has been created in the same resource group.

Conclusion

We have successfully created an Azure Logic App that sends an email using a serverless approach. You learned:

How to create a Resource Group and a Logic App via GUI and CLI.

How to define a trigger (recurrence or HTTP) and configure the send email action.

How to verify and test runs in the Azure Portal.

This project requires no up-front credit if you use the Azure Free Tier and keep usage minimal.

What is Cloud Computing ?

Cloud computing delivers computing resources (servers, storage, databases, networking, and software) over the internet, allowing businesses to scale and pay only for what they use, eliminating the need for physical infrastructure.


  • AWS: The most popular cloud platform, offering scalable compute, storage, AI/ML, and networking services.
  • Azure: A strong enterprise cloud with hybrid capabilities and deep Microsoft product integration.
  • Google Cloud (GCP): Known for data analytics, machine learning, and open-source support.