简体   繁体   English

在ForEach活动Azure Data Factory中的活动中进行迭代

[英]Iterate in Activity within ForEach activity Azure Data Factory

I have a MetaData activity and a foreach activity connected to it. 我有一个MetaData活动和一个与之连接的foreach活动。

在此处输入图片说明

I run this ForEach activity sequentially and here is the item it iterates over: 我依次运行此ForEach活动,这是对其进行迭代的项目:

在此处输入图片说明

I have a copy activity within this foreach activity: 我在此foreach活动中有一个复制活动:

在此处输入图片说明

So I have 4 childItems that I get from my meta data activity. 因此,我从元数据活动中获得了4个childItem。 And I need to set the folder name in data lake based on the childItem value. 而且我需要基于childItem值在数据湖中设置文件夹名称。 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

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 . 根据文档 ,您可以使用@item().XXX而不是@activity('GetMetaData').output.ChildItems[index].XXX来引用for-each活动中的属性。 The items property is the collection and each item in the collection is referred to by using the @item() . items属性是集合,并且使用@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. 在ForEach活动中,提供要迭代的属性项数组。”使用@item()遍历ForEach活动中的单个枚举。例如,如果项是一个数组:[1、2、3], @item()在第一次迭代中返回1,在第二次迭代中返回2,在第三次迭代中返回3。

Also,please see this marked answer : Azure Data Factory get data for "For Each"component from query 另外,请参见此标记的答案: Azure数据工厂从查询中获取“对于每个”组件的数据

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM