首页 > 解决方案 > 如何执行 Azure 数据工厂管道 X 次(对于 X 个不同的参数值)?

问题描述

我有一个每天在特定时间触发的管道,效果很好。该管道获取当前日期作为输入参数,这也很好。

现在我正在做同一管道的替代版本来模拟过去的日期,其中参数是日期值(例如 2018 年 5 月 23 日的“2018-05-23”)。但是,如果我想在 2018 年全年运行管道(所以我需要 365 个不同的参数),我该怎么做?

当然,我可以在 1 月 1 日手动触发它,然后是 1 月 2 日,依此类推,但这需要很长时间。我想触发 1 月 1 日,然后在 1 月 1 日结束后依次在一年中的其他 364 天执行管道。

提前致谢!

标签: azureazure-data-factoryazure-data-factory-2

解决方案


So... to loop through a series of dates, I'd suggest populating an input parameter with an array of date values (you can generate this in a straightforward way through code, and pass this as a parameter to your pipeline).

Then, in your pipeline, you can define a ForEach loop, iterating through each of the date entries in your parameter, executing the pipeline for each date.

Based on your requirement to run the pipelines in sequence, without parallelism, just be sure to set isSequential to true in your pipeline's ForEach definition. Something like this, as a simple example:

{  
   "name":"...",
   "type":"ForEach",
   "typeProperties":{  
      "isSequential":"true",
        "items": {
            "value": "@pipeline().parameters.datesToProcess",
            "type": "Expression"
        },
      "activities":[  
         { 
            ...
         }
      ]
    }
}

You can read more about ForEach in this article.


推荐阅读