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
lastModified
date of that blob, we can iterate through each file, add column to it which has the current blob'slastModified
date, 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 Metadata
to 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 each
activity, I obtained thelastModified
of each file using anotherget metadata
activity inside the for each.
- The dataset of this
Get Metadata2
is configured as shown below:
- Now I have copied these files into
output1
folder by adding an additional column where I gave the following dynamic content (lastModified
from 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
final
folder.
- The following is the final output for reference: