Introduction
Azure Logic Apps enables you to automate workflows without writing much code. This low-code Microsoft Azure solution connects your cloud and on-premise services. In this tutorial, you will create a Logic App that monitors a Blob Storage container and sends an email for every new file. This approach is ideal for beginners who want to understand the basics of automated workflows.
Prerequisites
- Active Azure account
- Azure CLI installed
- Basic knowledge of JSON
- Access to an Outlook or Office 365 account
Create the Base Definition
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {},
"contentVersion": "1.0.0.0",
"outputs": {},
"triggers": {}
}
}This JSON file forms the minimal structure of a Logic App. It defines the schema, actions, triggers, and version. Copy it directly into the Azure designer to initialize your workflow.
Configure the Trigger
The trigger monitors events. Here we use a Blob Storage trigger that fires when a file is added.
Add the Blob Trigger
{
"When_a_blob_is_added_or_modified": {
"type": "ApiConnection",
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['azureblob']['connectionId']"
}
},
"method": "get",
"path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('AccountNameFromSettings'))}/files",
"queries": {
"folderPath": "/uploads",
"maxFileCount": 10
}
},
"recurrence": {
"frequency": "Minute",
"interval": 1
}
}
}This trigger monitors the /uploads folder every minute. It uses an existing Azure Blob connection. Replace the account name with your own.
Add the Send Email Action
{
"Send_an_email_(V2)": {
"type": "ApiConnection",
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['office365']['connectionId']"
}
},
"method": "post",
"path": "/v2/Mail",
"body": {
"To": "admin@exemple.com",
"Subject": "Nouveau fichier détecté",
"Body": "Un nouveau fichier a été ajouté : @{triggerBody()?['Name']}"
}
}
}
}This action sends an email via Office 365 as soon as a file is detected. Use expressions to include the file name dynamically.
Add Error Handling
{
"Scope": {
"type": "Scope",
"actions": {
"Send_an_email_(V2)": { ... }
},
"runAfter": {}
},
"Configure_run_after": {
"type": "If",
"expression": {
"or": [
{
"equals": [
"@action()['status']",
"Failed"
]
}
]
}
}
}Error handling uses a scope and a runAfter condition. This allows you to send an alert if the main workflow fails.
Deploy via CLI
#!/bin/bash
az group create --name LogicAppRG --location westeurope
az logic workflow create --resource-group LogicAppRG \
--name MonPremierWorkflow --definition workflow-base.json \
--location westeuropeThis Bash script creates the resource group and then deploys the Logic App with the JSON definition. Run it after configuring Azure CLI.
Best Practices
- Name your actions and triggers clearly
- Use variables for reusable values
- Enable logging for debugging
- Test each step in designer mode
- Protect secrets with Azure Key Vault
Common Errors to Avoid
- Forgetting to configure API connections
- Using incorrect Blob paths
- Ignoring connector rate limits
- Not testing workflows in iterative mode
Go Further
Deepen your skills with our complete Azure training courses.