简体   繁体   中英

Azure ADF V2 ForEach File CopyData from Blob Storage to SQL Table

I need to design an ADF pipeline to copy a CSV file created on a particular Blob Store folder path named "Current" to a SQL table. After successful copy, i'll have to move the file to an archive folder.

Things i've accomplished : I'm using a Copy Data Activity that copies the CSV file and loads into my SQL table. On success, another copy data activity will copy the CSV file from "Current" folder to "Archive", after this i have a Delete activity that deletes the file from Current Folder.

Issue : This is totally fine where there is only one file at a time. But i want redesign this to handle multiple files imports. I want make use of ForEach activity. Please help.

You need to add a Get Metadata activity before the for-each. The Get Metadata activity will get the files in the current directory and pass them to the For-Each. You connect it to your Blob storage folder and specify the file mask. The output of the activity will need to be the input for your for-each loop. Something like this..@activity('Get Metadata').output. By the way how are you triggering this ADF pipeline? Another way to accomplish this would be to setup an event trigger to run this pipeline whenever a file is created in that blob directory. Here are the steps to use the For-Each on files in a storage container.

  1. Set the Get Metadata argument to "Child Items" child_items-截图
  2. In your For-Each set the Items to @activity('Get Metadata1').output.childitems

对于每个图像

  1. In the Source Dataset used in your Copy Activity create a parameter named FileName.

文件名参数

  1. Set the file path to use the parameter文件路径参数

  2. On the Copy Activity set the FileName parameter to @item().name 在此处输入图片说明

To finish you'll need to set the sink to whatever you need. That should do it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM