Azure | Creating Azure Logic Apps to integrate workflows for sending notifications about changes within a Blob Storage container
Azure Logic Apps is a cloud service that allows you to automate workflows by integrating various apps, data, and services. It provides a visual designer to build workflows without writing code.
Note I highlighted screenshots with a yellow color to focus on some important informations.
Scenario
Let’s consider a scenario where you want to automate the process of sending an email notification whenever a new file is uploaded to a specific folder in Azure Blob Storage.
Steps to Create the Logic App
1. Create a Logic App
- Go to the Azure Portal and create a new Logic App resource.
- Choose a name, subscription, resource group, and region.
- Click “Review + Create” and then “Create”.
After a few seconds, we will receive a message confirming that the deployment was successfully completed.
2. Trigger: When a New File is Added (Blob Storage)
- In the Logic App Designer, search for and select the “When a new blob is added or modified (properties only)” trigger.
- Sign in with your Azure account and select the Azure Blob Storage account and container where files will be uploaded.
- Optionally, specify a prefix filter if you want to monitor files in a specific folder : lab-container.
Important For further information on how we created the blob storage and uploaded the files within the container, please refer to the following post : Creating an Azure Storage Account and Uploading Files to a Container.
3. Action: Send an Email (Office 365 Outlook)
- Add a new step after the trigger.
- Search for and select the “Send an email (V2)” action.
- Sign in with your Office 365 Outlook account.
- Enter the recipient’s email address, subject, and body.
- You can use dynamic content from the trigger (e.g., filename, file URL) in the email body.
4. Save and Test
- Click “Save” to save your Logic App.
- Upload a new file to the blob storage.
- Click “Run” to manually trigger the Logic App and test it.
- You will receive a notification email about the newly uploaded file.
Caution To allow your Logic App access to your blob storage, you should create a new role assignment with “Storage Blob Data Reader privileges”. The configuration shoud be done on the Blob storage side.
Example Logic App Definition code
Below is an example of a the Logic App workflow definition code that I created :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"contentVersion": "1.0.0.0",
"triggers": {
"Quand_un_objet_blob_est_ajouté_ou_modifié_(propriétés_uniquement)_(V2)": {
"type": "ApiConnection",
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['azureblob-1']['connectionId']"
}
},
"method": "get",
"path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('hbolajraf00storage'))}/triggers/batch/onupdatedfile",
"queries": {
"folderId": "JTJmbGFiLWNvbnRhaW5lcg==",
"maxFileCount": 10,
"checkBothCreatedAndModifiedDateTime": false
}
},
"recurrence": {
"interval": 1,
"frequency": "Day"
},
"conditions": [],
"splitOn": "@triggerBody()",
"metadata": {
"JTJmbGFiLWNvbnRhaW5lcg==": "/lab-container"
}
}
},
"actions": {
"Envoyer_un_e-mail_(V2)": {
"type": "ApiConnection",
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['outlook']['connectionId']"
}
},
"method": "post",
"body": {
"To": "hassan.bolajraf@gmail.com",
"Subject": "New File was Uploaded",
"Body": "<p>Hello,<br><br>A new file $$filename was uploaded within the Blob storage : hbolajraf00storage.<br><br>Regards<br>Hassan BOLAJRAF</p>",
"Importance": "Normal"
},
"path": "/v2/Mail"
},
"runAfter": {}
}
},
"outputs": {},
"parameters": {
"$connections": {
"type": "Object",
"defaultValue": {}
}
}
},
"parameters": {
"$connections": {
"value": {
"azureblob-1": {
"id": "/subscriptions/4928c257-de8f-44ad-8242-55d442f71cae/providers/Microsoft.Web/locations/centralus/managedApis/azureblob",
"connectionId": "/subscriptions/4928c257-de8f-44ad-8242-55d442f71cae/resourceGroups/AzureLogicApp/providers/Microsoft.Web/connections/azureblob-1",
"connectionName": "azureblob-1",
"connectionProperties": {
"authentication": {
"type": "ManagedServiceIdentity"
}
}
},
"outlook": {
"id": "/subscriptions/4928c257-de8f-44ad-8242-55d442f71cae/providers/Microsoft.Web/locations/centralus/managedApis/outlook",
"connectionId": "/subscriptions/4928c257-de8f-44ad-8242-55d442f71cae/resourceGroups/AzureLogicApp/providers/Microsoft.Web/connections/outlook",
"connectionName": "outlook"
}
}
}
}
}
Replace <recipient-email>
, <folder-id>
, <subscription-id>
, and <resource-group>
with appropriate values.
What next ?
Azure Logic Apps simplifies automation tasks by providing a user-friendly interface to create powerful workflows, connecting various services and applications seamlessly.