MAK
MAK

Reputation: 1288

Iterate in Activity within ForEach activity Azure Data Factory

I have a MetaData activity and a foreach activity connected to it.

enter image description here

I run this ForEach activity sequentially and here is the item it iterates over:

enter image description here

I have a copy activity within this foreach activity:

enter image description here

So I have 4 childItems that I get from my meta data activity. And I need to set the folder name in data lake based on the childItem value. In order to access the Child Item I have to use the zero based index. Can I set it dynamically? I assumed there would be something since it is already in a loop and is running sequentially. So I would not have to do

@activity('GetMetaData').output.ChildItems[3].name

but use the index

@activity('GetMetaData').output.ChildItems[index].name

Upvotes: 3

Views: 11343

Answers (1)

Jay Gong
Jay Gong

Reputation: 23782

Based on the document,you could refer to the properties inside the for-each activity by using @item().XXX,instead @activity('GetMetaData').output.ChildItems[index].XXX. The items property is the collection and each item in the collection is referred to by using the @item().

In the ForEach activity, provide an array to be iterated over for the property items." Use @item() to iterate over a single enumeration in ForEach activity. For example, if items is an array: [1, 2, 3], @item() returns 1 in the first iteration, 2 in the second iteration, and 3 in the third iteration.

Also,please see this marked answer :Azure Data Factory get data for "For Each"component from query

Upvotes: 2

Related Questions