Home > Enterprise >  how to segregate files in a blob storage using ADF copy activity
how to segregate files in a blob storage using ADF copy activity

Time:12-04

I have a copy data activity in ADF and I want to segregate the files into a different container based on the file type.

ex. Container A - .jpeg, .png Container B - .csv, .xml and .doc

My initial idea was to use 'if condition' and 'or' statement but looks like my approach won't work. I'd appreciate it if you could give some inputs.

enter image description here

CodePudding user response:

You should use the GetMetadata activity to first get all the file types that needs to be first passed to a CopyData activity which copies to Container A, and then add next Getmetadata activity to get file types for next copydata activity that copies to container B. so, your ADF pipeline may be like GetMetaData1 - > Copydata1 -> GetMetaData2 -> Copydata2. Refer how to use GetMetaData activity in this enter image description here

In ADF:

  1. Using the Get metadata activity, get the list of all files from the source container.

enter image description here

  1. Output of Get Metadata activity:

enter image description here

  1. Pass the output list to Foreach activity.

@activity('Get Metadata1').output.childitems

enter image description here

  1. Inside the Foreach activity, add If Condition activity to separate the files based on extension.

@or(contains(item().name, '.xml'),contains(item().name, '.csv'))

enter image description here

  1. If the condition is true, copy the current file to container1.

enter image description here

enter image description here

  1. If the condition returns false, copy the current file to container2 in False activity.

enter image description here

enter image description here

Files in the container after running the pipeline.

Container1:

enter image description here

Container2:

enter image description here

  • Related