I am copying many files into one with ADF Copy Activity but I want to add a column and grab the Blob's Last modified date on the Metadata like the $$FILEPATH.

Is there an easy way to do that as I only see System Variables related to pipeline details etc.
https://learn.microsoft.com/en-us/azure/data-factory/control-flow-system-variables
CodePudding user response:
Since the requirement is to add a column to each file where this column value is the
lastModifieddate of that blob, we can iterate through each file, add column to it which has the current blob'slastModifieddate, copy it into a staging folder.From this staging folder, you can use final copy activity to where you merge all the files in this folder to a single file in the final destination folder.
Look at the following demonstration. The following are my files in ADLS storage.

- I used
Get Metadatato get the name of files in this container (final and output1 folders are created in later stages, so they won't affect the process).

- Using the return filenames as items (
@activity('Get Metadata1').output.childItems) in thefor eachactivity, I obtained thelastModifiedof each file using anotherget metadataactivity inside the for each.

- The dataset of this
Get Metadata2is configured as shown below:

- Now I have copied these files into
output1folder by adding an additional column where I gave the following dynamic content (lastModifiedfrom get metadata2)
@activity('Get Metadata2').output.lastModified

- Now you can use a final copy data activity after this foreach to merge these files into a single file into the
finalfolder.

- The following is the final output for reference:


