Azure Logic Apps are a serverless cloud service that helps you automate workflows and integrate disparate applications and services.
Here’s a Logic App that sends an email notification when a new file is added to an Azure Blob Storage container.
{
"definition": {
"contentVersion": "1.0.0.0",
"parameters": {
"Run_After_Error_in_this_run": {
"type": "string",
"defaultValue": "false"
}
},
"triggers": {
"When_a_blob_is_added": {
"type": "ApiConnection",
"displayName": "When a blob is added",
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['azureblob']['connectionId']"
}
},
"method": "get",
"path": "/datasets/default/triggers/whennewfile=@{triggerBody()?['Name']}",
"queries": {
"folderPath": "/mycontainer"
}
}
}
},
"actions": {
"Send_an_email_notification": {
"type": "ApiConnection",
"displayName": "Send an email notification",
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['office365']['connectionId']"
}
},
"method": "post",
"body": {
"Subject": "New file added to blob storage: @{triggerBody()?['Name']}",
"Body": "A new file named @{triggerBody()?['Name']} has been added to the container.",
"To": "user@example.com"
},
"path": "/v2/Mail"
}
}
},
"outputs": {}
},
"parameters": {
"$connections": {
"type": "Object",
"defaultValue": {
"azureblob": {
"connectionId": "/subscriptions/YOUR_SUBSCRIPTION_ID/resourceGroups/YOUR_RESOURCE_GROUP/providers/Microsoft.Web/connections/azureblob",
"connectionName": "azureblob",
"api": {
"id": "/subscriptions/YOUR_SUBSCRIPTION_ID/providers/Microsoft.Web/locations/YOUR_LOCATION/managedApis/azureblob"
}
},
"office365": {
"connectionId": "/subscriptions/YOUR_SUBSCRIPTION_ID/resourceGroups/YOUR_RESOURCE_GROUP/providers/Microsoft.Web/connections/office365",
"connectionName": "office365",
"api": {
"id": "/subscriptions/YOUR_SUBSCRIPTION_ID/providers/Microsoft.Web/locations/YOUR_LOCATION/managedApis/office365"
}
}
}
}
}
}
This Logic App starts with a trigger that monitors an Azure Blob Storage container. When a new file appears in the /mycontainer folder, the trigger fires. The Send_an_email_notification action then takes the name of the new file and includes it in the subject and body of an email sent to user@example.com using Office 365 Outlook.
Logic Apps are built around a visual designer where you can drag and drop connectors to build your workflow. These connectors represent services like Azure Blob Storage, Office 365, SQL Server, Salesforce, and hundreds more. Each connector has triggers and actions that form the building blocks of your automation. The designer translates your visual workflow into a JSON definition that Azure executes.
You control the flow of your Logic App using conditions, loops, and parallel branches. For instance, you could add a condition to only send an email if the new file’s name contains a specific keyword, or use a For each loop to process multiple files. The expression language allows for dynamic data manipulation, pulling data from previous steps and transforming it as needed. The triggerBody()?['Name'] expression, for example, accesses the name property of the blob that triggered the workflow.
A key concept often overlooked is the state management of a Logic App run. Each execution of a Logic App is a distinct run, and its state is preserved between steps. If a step fails, you can configure the Logic App to retry, or to proceed to another step based on the failure. This inherent statefulness is what allows complex, multi-step processes to be automated reliably without needing to manage your own state persistence mechanisms. The run history provides a detailed audit trail of each execution, showing inputs, outputs, and any errors encountered.
The next logical step is to explore more advanced error handling and retry policies within your Logic App runs.