Azure数据工厂动态内容获取月份名称

时间:2020-11-02 09:10:46

标签: azure azure-data-factory azure-data-factory-2 azure-data-factory-pipeline

我想每个月通过Azure数据工厂从网站中提取数据。是否可以通过动态内容功能更改带有月名称的每个月的URL?

{{static URL}} / TestFile_October_2020.zip

{{static URL}} / TestFile_November_2019.zip

{{静态URL}} / TestFile_December_2020.zip

2 个答案:

答案 0 :(得分:1)

我们可以在ADF管道中定义数组类型变量,如下所示
[{"id": 1,"Value": "January"},{"id": 2,"Value": "February"},{"id": 3,"Value": "March"},{"id": 4,"Value": "April"},{"id": 5,"Value": "May"},{"id": 6,"Value": "June"},{"id":7,"Value": "July"},{"id": 8,"Value": "August"},{"id": 9,"Value": "September"},{"id": 10,"Value": "October"},{"id": 11,"Value": "November"},{"id": 12,"Value":"December"}]

  1. 我们可以预先定义几个变量。

enter image description here

  1. 然后我们可以遍历Array变量。

enter image description here

  1. 在ForEach活动中,我们可以将@item().value存储在变量MonthString

enter image description here

  1. 然后在If Condition活动中,我们可以使用@equals(item().id,int(subString(utcnow(),5,2)))选择当前月份的值。在这里,我们需要使用int()函数将字符串类型转换为int类型。

enter image description here

  1. 然后,我们可以在True活动中设置一个Web活动。我们可以使用@concat(variables('BasicURL'),concat('/TestFile_',variables('MonthString')),concat('_',substring(utcnow(),0,4),'.zip'))来构建查询字符串。

enter image description here

  1. 这样的输出:

enter image description here

如果具有Azure SQL,则可以创建一个表来存储此数组,并使用“查找”活动来查找“值”,这将变得更加容易。

答案 1 :(得分:0)

您可以使用格式为“ MMMM”的函数“ formatDateTime”在动态内容中获取完整的月份名称。您可以参考documentation