简体   繁体   中英

Azure Data Factory Dataset Dynamic Folder Path

I have a data set that resides under a folder path where the date is dynamic (eg rootfolder/subfolder/yyyy/mm/dd/subfolder/subfolder), and I am trying to pull it with a copy activity. So far I cannot get Data Factory to recognize that my date is dynamic...

This is the code that I have tried so far:

["rootfolder/subfolder/subfolder/subfolder/subfoler/@{formatDateTime(utcnow(),'yyyy')}/@{formatDateTime(utcnow(),'MM')}/@{formatDateTime(utcnow(),'dd')}/subfolder/file"]

You need to make use of concat function provided by data factory.

@concat('rootfolder/subfolder/subfolder/subfolder/subfolder/',formatDateTime(utcnow(),'yyyy'),'/',formatDateTime(utcnow(),'MM'),'/',formatDateTime(utcnow(),'dd'),'/subfolder/file')

The concat function is similar as in programming languages which concats the strings.

More details: Azure Data Factory Loop Through Files

Just to build pm Anish K answer you can also shorten this a bit by using formatting

formatDateTime(utcnow(),'yyyy/MM/dd')

So final answer would be

@concat('rootfolder/subfolder/subfolder/subfolder/subfolder/',formatDateTime(utcnow(),'yyyy//MM/dd'),'/subfolder/file')

In case you want to learn a bit more on parametrization on ADF feel free to check out this video https://youtu.be/pISBgwrdxPM

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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