Can you add nested ForEach activity in ADF Pipelines?
Pratik Somaiya
Select an image from your device to upload
The ForEach activity in Azure Data Factory is used to iterate over items specified in the input. Is it possible to have nested ForEach activities in a pipeline?
Yes, it is possible to have nested ForEach activities in ADF pipelines. The ForEach activity in ADF allows you to iterate over a collection of items specified in the input. This can be useful when you need to perform a set of actions on each item in the collection.
To create nested ForEach activities, you can simply add a ForEach activity within another ForEach activity. This allows you to iterate over multiple levels of collections.
Here is an example of how you can use nested ForEach activities in an ADF pipeline:
{ "name": "NestedForEachPipeline", "properties": { "activities": [ { "name": "OuterForEach", "type": "ForEach", "foreach": { "items": { "value": "@pipeline().parameters.OuterItems", "type": "Expression" } }, "activities": [ { "name": "InnerForEach", "type": "ForEach", "foreach": { "items": { "value": "@pipeline().parameters.InnerItems", "type": "Expression" } }, "activities": [ { "name": "Action", "type": "WebActivity", "dependsOn": [], "linkedServiceName": { "referenceName": "AzureBlobStorageLinkedService", "type": "LinkedServiceReference" }, "typeProperties": { "url": "https://example.com", "method": "GET" } } ] } ] } ], "parameters": { "OuterItems": { "type": "Array", "defaultValue": [ "item1", "item2", "item3" ] }, "InnerItems": { "type": "Array", "defaultValue": [ "subitem1", "subitem2", "subitem3" ] } } }}
{
"name": "NestedForEachPipeline",
"properties": {
"activities": [
"name": "OuterForEach",
"type": "ForEach",
"foreach": {
"items": {
"value": "@pipeline().parameters.OuterItems",
"type": "Expression"
}
},
"name": "InnerForEach",
"value": "@pipeline().parameters.InnerItems",
"name": "Action",
"type": "WebActivity",
"dependsOn": [],
"linkedServiceName": {
"referenceName": "AzureBlobStorageLinkedService",
"type": "LinkedServiceReference"
"typeProperties": {
"url": "https://example.com",
"method": "GET"
]
],
"parameters": {
"OuterItems": {
"type": "Array",
"defaultValue": [
"item1",
"item2",
"item3"
"InnerItems": {
"subitem1",
"subitem2",
"subitem3"
The pipeline contains an outer ForEach activity that iterates over the OuterItems array, and within that, there is an inner ForEach activity that iterates over the InnerItems array. Inside the inner ForEach activity, there is a WebActivity that performs a GET request to a URL.