ForEach in LogicApp

I have struggled a while to get ForEach looping working in my logic app. In this scenario I call an Azure Function FilterEvents (post), to filter the results from an Http Call. The output of this function is an array. So I added a ForEach loop to go through the array. Within the ForEach section, you have an element named actions. Here you will have to add the actions you want to include in your loop. Makes sense, but I didn’t know I could nest actions that way. Next note the element foreach with value¬†@body(‘FilterEvents’). This means you are going through the output of the FilterEvents action one by one. Finally the most important part: How do you refer to the items in the array? As you can see, that’s via the Item element:¬†@{item().IntegrationId}. Note that I don’t want to return json, but a string. That’s why I use the expression notation @{ …}, so with the curly braces. Within the loop I call a child workflow. Like I said, you can add multiple actions within a loop, but I wanted a bit more modularization. “FilterEvents”: { “type”: “Function”, “inputs”: { “body”: “@body(‘HTTP’)”, “function”: { “id”: “/subscriptions/1ea9735d-00df-4375-86d5-d0d35362dd7f/resourceGroups/ahak-appfunctions/providers/Microsoft.Web/sites/ahak-functions/functions/FilterEvents” } }, “runAfter”: { “HTTP”: [ “Succeeded” ] } }, “ForEachEvent”: { “type”: “Foreach”, “foreach”: “@body(‘FilterEvents’)”, “actions”: { “ProcessAGADocuments”: { “type”: “Workflow”, “inputs”: { “host”: { “triggerName”: “manual”, “workflow”: { “id”: “/subscriptions/1ea9735d-00df-4375-86d5-d0d35362dd7f/resourceGroups/ahak-appservices/providers/Microsoft.Logic/workflows/ProcessAGADocuments” } }, “body”: { “IntegrationId”: “@{item().IntegrationId}” } }, “runAfter”: {} } }, “runAfter”: { “FilterEvents”: [ “Succeeded” ] } } }