Data Factory Childitem modified or created date

穿精又带淫゛_ 提交于 2021-02-10 14:33:24

问题


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.

  1. First, I created a table for logging.
create table Copy_Logs (
    Copy_File_Name varchar(max),
    Last_modified datetime
)
  1. In ADF, I'm using Child Items at Get Metadata1 activity to get the file list of the folder.

  2. Then add dynamic content @activity('Get Metadata1').output.childItems at ForEach1 activity.

  3. Inside the ForEach1 activity, using Last modified at Get Metadata2 activity.

In the dataset of Get Metadata2 activity, I key in @item().name as follows.

  1. 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 of CopyFiles_To_Azure activity.

  2. 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
  1. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!