Azure Logic Apps: Trigger on Blob Event, Filter Content & Insert into SQL
🔹 Step 1: Create a Logic App
- Go to Azure Portal & search for Logic Apps.
- Click “Create” → Choose “Logic App (Consumption)”.
- Set the resource group, name, and region.
- Click “Review + Create” and then “Create”.
🔹 Step 2: Start with Blob Trigger
- Open the Logic App Designer.
- Choose the trigger: “When a blob is added or modified (properties only)”.
- Sign in to connect your storage account.
-
Select:
- Storage account
- Container (e.g.,
studentdata
)
🔹 Step 3: Get Blob Content
- Click “+ New Step”.
- Add action: “Get blob content using path”.
-
Set:
- Blob path = dynamic value:
Path
- Storage account connection = same as before
🔹 Step 4: Parse Blob Content (Assume JSON)
- Add action: “Parse JSON”.
- Content =
Blob content
from previous step.
- Generate schema by uploading or pasting a sample. For example:
[
{
"Name": "John",
"RollNumber": 101,
"TotalMarks": 85
},
{
"Name": "Jane",
"RollNumber": 102,
"TotalMarks": 40
}
]
🔹 Step 5: Add Condition to Filter Records
- Add action: “For Each” loop →
Parse JSON - Body
.
- Inside the loop, add “Condition”:
-
Set condition:
item()?['TotalMarks']
is greater than 50
- Inside the "If yes" branch, continue to next step.
🔹 Step 6: Insert into SQL Server
- Add action: “SQL Server – Insert row (V2)”.
- Sign in to connect to your Azure SQL or on-prem SQL with gateway.
-
Select:
- Server & Database
- Table (e.g.,
Students
)
-
Map fields from parsed JSON:
Name
→ item()?['Name']
RollNumber
→ item()?['RollNumber']
TotalMarks
→ item()?['TotalMarks']
🔹 Step 7: Finalize & Save
- Save your Logic App and run a test by uploading a blob JSON file into the container.
- Only records with TotalMarks > 50 will be inserted into SQL Server.
📦 Blob Upload Sample (in .NET)
public async Task UploadStudentBlobAsync(Student student)
{
var json = JsonConvert.SerializeObject(student);
var client = new BlobContainerClient(connectionString, "studentdata");
var blob = client.GetBlobClient($"{student.RollNumber}.json");
using var stream = new MemoryStream(Encoding.UTF8.GetBytes(json));
await blob.UploadAsync(stream, overwrite: true);
}
📊 Sample SQL Table Schema
CREATE TABLE Students (
Id INT IDENTITY PRIMARY KEY,
Name NVARCHAR(100),
RollNumber INT,
TotalMarks INT
);
🎯 What You Achieved
- Created a Logic App to listen for blob uploads
- Parsed JSON content and filtered based on Total Marks
- Inserted filtered records into a SQL table