blob trigger logic apps code for medium article
Figure 0: Blob Triggered LogicΒ App
Blob Trigger Logic Apps β CSV Automation with Event Grid
This repository contains an end-to-end example of automating CSV ingestion and processing in Azure Logic Apps, triggered by Blob Storage updates. It demonstrates two approaches:
Blob Trigger β baseline solution that reacts when a blob is added/updated.
Event Grid β improved, real-time, event-driven solution with precise filtering at the source.
π Features
Blob Monitoring β Watches a Blob container for new or updated files.
CSV Parsing β Decodes base64 blob content into raw text, normalizes line breaks, and skips headers.
Row & Column Mapping β Splits rows into columns using split() and maps values dynamically.
Loop Actions β Iterates over CSV rows to trigger downstream actions (e.g., send emails, API calls, DB inserts).
Security β Masks sensitive inputs/outputs in Logic Apps settings.
Event Grid Upgrade β Uses prefix/suffix filters to only trigger on .csv files, eliminating noise and polling.
π Setup Prerequisites
Azure subscription
Azure Blob Storage account
Azure Logic Apps
(Optional) Azure Event Grid for real-time events
Steps (Blob Trigger)
Create a Logic App with the trigger: When a blob is added or updated.
Add WDL expressions to filter files by name and timestamp.
@greaterOrEquals( ticks(triggerBody()?['properties']?['lastModified']), ticks(addMinutes(utcNow(), -5)) )
@contains(toLower(triggerBody()?['properties']?['blobName']), 'list')
Decode blob content using:
base64ToString(body('Read_blob_content')?['content']?['$content'])
Split CSV lines and skip header:
@skip(outputs('Compose_Lines'), 1)
Loop through rows, split by commas, and take action. Example: split(item(), ',')[0]
Steps (Event Grid β Recommended)
Create an Event Subscription in your Blob Storage account.
Event Type: Microsoft.Storage.BlobCreated
Prefix filter: /blobServices/default/containers//blobs/
Suffix filter: .csv
Point the Event Grid subscription to your Logic App endpoint.
In Logic Apps, select trigger: When a resource event occurs.
Authenticate with Managed Identity (recommended for private networking).
π Comparison Feature Blob Trigger Event Grid Execution Model Polling Push (real-time) Filtering Inside Logic App (WDL) At the source (prefix/suffix) Latency Minutes Instant Cost Efficiency Risk of extra executions Lower, event-driven Use Case Quick start, simple flows Scalable, production-grade π Security Best Practices
Mask sensitive inputs/outputs in Logic App actions.
Use Managed Identity for authentication where possible.
Restrict access to Blob containers with RBAC and private networking.
π Repo Structure /blob_trigger_logic_apps βββ logicapp.json # Example Logic App definition βββ README.md # This file
π References
Medium Article β Stop Writing Cron Jobs. Start Automating with Event Grid + Logic Apps
Azure Logic Apps Docs
Azure Event Grid Docs
π¨βπ» Author
Tomas Suarez
π GitHub: tomasdevelopment
πΌ LinkedIn: Tomas Suarez