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.
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
In ADF:
- Using the
Get metadata
activity, get the list of all files from the source container.
- Output of Get Metadata activity:
- Pass the output list to
Foreach
activity.
@activity('Get Metadata1').output.childitems
- Inside the
Foreach
activity, addIf Condition
activity to separate the files based on extension.
@or(contains(item().name, '.xml'),contains(item().name, '.csv'))
- If the condition is true, copy the current file to container1.
- If the condition returns false, copy the current file to container2 in False activity.
Files in the container after running the pipeline.
Container1:
Container2: