Azure Logic Apps

Connecting Services in Azure Logic Apps

Logic Apps provides a rich set of connectors that let you integrate Azure services, SaaS applications, and on‑premises systems without writing code. In this tutorial, you’ll learn how to add a connector, configure authentication, and pass data between services.

Step 1 – Add a Trigger

Every Logic App starts with a trigger. For example, to run the workflow when a new email arrives in Outlook:

{
  "type": "Microsoft.Trigger",
  "name": "When_a_new_email_arrives_(V3)",
  "inputs": {
    "host": {
      "connection": {
        "name": "@parameters('$connections')['office365']['connectionId']"
      }
    },
    "parameters": {
      "folderPath": "Inbox"
    }
  }
}

Step 2 – Add an Action (Connect to Azure Storage)

After the trigger fires, store the email content in a Blob storage container:

{
  "type": "Microsoft.Actions",
  "name": "Create_blob_(V2)",
  "inputs": {
    "host": {
      "connection": {
        "name": "@parameters('$connections')['azureblob']['connectionId']"
      }
    },
    "parameters": {
      "folderPath": "emails",
      "fileName": "@{triggerOutputs()?['subject']}.txt",
      "content": "@{triggerBody()?['BodyPreview']}"
    }
  }
}

Step 3 – Configure Connections

Navigate to the API connections blade in the Azure portal and create the required connections. For Outlook and Azure Blob, the flow is:

  1. Click + Create in the Connections list.
  2. Select the connector (e.g., Office 365 Outlook).
  3. Sign in with your account and grant permissions.
  4. Repeat for Azure Blob Storage.

Step 4 – Test the Logic App

Send an email to the monitored mailbox. In the Azure portal, go to Runs history to see the execution details. The email body should appear as a blob in the emails container.

Run History screenshot

Full Logic App Definition

The JSON below represents the complete Logic App with the trigger and action defined above.

{
  "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "$connections": {
      "defaultValue": {},
      "type": "Object"
    }
  },
  "triggers": {
    "When_a_new_email_arrives_(V3)": {
      "type": "ApiConnection",
      "inputs": {
        "host": {
          "connection": {
            "name": "@parameters('$connections')['office365']['connectionId']"
          }
        },
        "method": "get",
        "path": "/v3/Mail/Inbox/Message",
        "queries": {
          "folderPath": "Inbox"
        }
      }
    }
  },
  "actions": {
    "Create_blob_(V2)": {
      "type": "ApiConnection",
      "inputs": {
        "host": {
          "connection": {
            "name": "@parameters('$connections')['azureblob']['connectionId']"
          }
        },
        "method": "post",
        "path": "/v2/datasets/default/files",
        "queries": {
          "folderPath": "emails",
          "fileName": "@{triggerOutputs()?['subject']}.txt"
        },
        "body": {
          "contentBytes": "@base64(triggerBody()?['BodyPreview'])"
        }
      }
    }
  },
  "outputs": {}
}