Azure数据工厂-根据json配置文件将文件复制到文件夹列表

时间:2020-08-25 13:57:02

标签: azure azure-data-factory

我正在尝试使用Azure数据工厂读取json文件并根据其包含的配置复制文件。

json文件:

{
    "FolderConfig": [
     {   
        "Source": "/pub/example",
        "Destination": "/FOL1"
     },
     {
        "Source": "/pub/example",
        "Destination": "/FOL2"
     }
    ]
}

这个想法是循环遍历FolderConfig中的对象并对其进行foreach。

然后foreach将文件从源复制到目标

我尝试使用将“源数据集”设置为json文件的Lookup活动,这将提供以下输出:

{
    "count": 1,
    "value": [
        {
            "FolderConfig": [
                {
                    "Source": "/pub/example1",
                    "Destination": "/FOL1"
                },
                {
                    "Source": "/pub/example2",
                    "Destination": "/FOL2"
                }
            ]
        }
    ],
    "effectiveIntegrationRuntime": "integrationDebugRuntime1",
    "billingReference": {
        "activityType": "PipelineActivity",
        "billableDuration": [
            {
                "meterType": "SelfhostedIR",
                "duration": 0.016666666666666666,
                "unit": "Hours"
            }
        ]
    },
    "durationInQueue": {
        "integrationRuntimeQueue": 2
    }
}

然后我在ForEach活动中使用此输出,并将“ Items”设置为 '@activity('Lookup1')。output.value [0] .FolderConfig'

ForEach遍历FolderConfig数组,在这里我使用“复制数据”活动。

在“复制数据”活动中,我可以使用动态内容指定来源: enter image description here

但是对于目标接收器,我似乎无法使用ForEach项目中的动态内容

enter image description here

有人对如何指定可变目标有想法吗?

感谢您的帮助!

1 个答案:

答案 0 :(得分:1)

请尝试以下操作:

首先:ForEach活动中的“项目”应如下所示:

@activity('Lookup1').output.value[0].FolderConfig

第二个:在接收器上单击“打开”按钮(Azure Blob存储) enter image description here

最终:添加此动态内容

@item().Destination

enter image description here