添加动态内容 - Azure 数据工厂 ADF
Add Dynamic Content - Azure Data Factory ADF
我需要在 ADF 中添加动态内容。以这样一种方式,它需要获得上个月的日期,如下所示。
结果:2018-12.csv.zip
这可以通过使用 https://docs.microsoft.com/en-us/azure/data-factory/control-flow-expression-language-functions 来完成。
可能的解决方案:
我会建议你在这里使用 3 个参数。
此解决方案使用 trigger().startTime,但您也可以使用 utcnow()。
注意:adddays(trigger().startTime,-31,'MM') 将 return 12 作为月份,因为该月份是 31 天前。如果您的触发器是在该月的 5 日或该月的第一天,那么您可以使用 -2。
processYear = @formatDateTime(adddays(trigger().startTime,-31), 'yyyy')
processMonth = @formatDateTime(adddays(trigger().startTime,-31), 'MM')
result = @concat(pipeline().parameters.processYear,'-',pipeline().parameters.processMonth,'.csv.zip').
希望这对您有所帮助。
如果我知道日期但我每天都是 运行 我的数据工厂,则上述案例有效。所以下面的效果更好。
@concat(substring(string(if(equals(int(formatDateTime(utcnow(), 'MM')),01), sub(int(formatDateTime(utcnow(), 'yyyyMM' )),89),sub(int(formatDateTime(utcnow(),'yyyyMM')),1))),0,4),'-',substring(string(if(equals(int(formatDateTime( utcnow(), 'MM')),01), sub(int(formatDateTime(utcnow(), 'yyyyMM')),89),sub(int(formatDateTime(utcnow(),'yyyyMM')),1))),4,2),'.csv.zip')
感谢任何更改。
如果您将日期设置为 28 日,然后减去 30 天,那么您应该可以从任何日期进入上个月。然后简单地格式化为yyyy-MM
,例如
@concat(formatDateTime(adddays(formatDateTime(utcnow(), 'yyyy-MM-28'),-30),'yyyy-MM'),'.csv.zip')
@concat(formatDateTime(subtractFromTime(utcNow(),1,'Month'), 'yyyy-MM'), '.csv.zip')
我需要在 ADF 中添加动态内容。以这样一种方式,它需要获得上个月的日期,如下所示。
结果:2018-12.csv.zip
这可以通过使用 https://docs.microsoft.com/en-us/azure/data-factory/control-flow-expression-language-functions 来完成。
可能的解决方案: 我会建议你在这里使用 3 个参数。 此解决方案使用 trigger().startTime,但您也可以使用 utcnow()。
注意:adddays(trigger().startTime,-31,'MM') 将 return 12 作为月份,因为该月份是 31 天前。如果您的触发器是在该月的 5 日或该月的第一天,那么您可以使用 -2。
processYear = @formatDateTime(adddays(trigger().startTime,-31), 'yyyy')
processMonth = @formatDateTime(adddays(trigger().startTime,-31), 'MM')
result = @concat(pipeline().parameters.processYear,'-',pipeline().parameters.processMonth,'.csv.zip').
希望这对您有所帮助。
如果我知道日期但我每天都是 运行 我的数据工厂,则上述案例有效。所以下面的效果更好。
@concat(substring(string(if(equals(int(formatDateTime(utcnow(), 'MM')),01), sub(int(formatDateTime(utcnow(), 'yyyyMM' )),89),sub(int(formatDateTime(utcnow(),'yyyyMM')),1))),0,4),'-',substring(string(if(equals(int(formatDateTime( utcnow(), 'MM')),01), sub(int(formatDateTime(utcnow(), 'yyyyMM')),89),sub(int(formatDateTime(utcnow(),'yyyyMM')),1))),4,2),'.csv.zip')
感谢任何更改。
如果您将日期设置为 28 日,然后减去 30 天,那么您应该可以从任何日期进入上个月。然后简单地格式化为yyyy-MM
,例如
@concat(formatDateTime(adddays(formatDateTime(utcnow(), 'yyyy-MM-28'),-30),'yyyy-MM'),'.csv.zip')
@concat(formatDateTime(subtractFromTime(utcNow(),1,'Month'), 'yyyy-MM'), '.csv.zip')