问题
I have a Data Factory V2 pipeline consisting of 'get metadata' and 'forEach' activities that reads a list of files on a file share (on-prem) and logs it in a database table. Currently, I'm only able to read file name, but would like to also retrieve the date modified and/or date created property of each file. Any help, please?
Thank you
回答1:
According to the MS documentation.
We can see File system
and SFTP
both support the lastModified property. But we only can get the lastModified of one file or folder at a time.
I'm using File system
to do the test. The process is basically the same as the previous post, we need to add a GetMetaData
activity to the ForEach activity.
This is my local files.
- First, I created a table for logging.
create table Copy_Logs (
Copy_File_Name varchar(max),
Last_modified datetime
)
In ADF, I'm using
Child Items
atGet Metadata1
activity to get the file list of the folder.Then add dynamic content
@activity('Get Metadata1').output.childItems
atForEach1
activity.Inside the
ForEach1
activity, usingLast modified
atGet Metadata2
activity.
In the dataset of Get Metadata2
activity, I key in @item().name
as follows.
Using
CopyFiles_To_Azure
activity to copy local files to the Azure Data Lake Storage V2. I key in@item().name
at the source dataset ofCopyFiles_To_Azure
activity.At
Create_Logs
activity, I'm using the following sql to get the info we need.
select '@{item().name}' as Copy_File_Name, '@{activity('Get Metadata2').output.lastModified}' as Last_modified
- In the end, sink to the sql table we created previously. The result is as follows.
回答2:
One way , I can think of is please add a new Getmetdata inside the FE loop and use paramterized dataset and pass a filename as the paramter . The below animation should helped , I did tested the same . HTH .
来源:https://stackoverflow.com/questions/65637406/data-factory-childitem-modified-or-created-date