Mitch Grant
Mitch Grant

Reputation: 11

Azure Data Factory Dataset Dynamic Folder Path

I have a data set that resides under a folder path where the date is dynamic (e.g. 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"]

Upvotes: 1

Views: 7151

Answers (2)

Adam Marczak
Adam Marczak

Reputation: 2351

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

Upvotes: 1

Anish K
Anish K

Reputation: 818

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

Upvotes: 2

Related Questions