Forum Discussion
Copy Data in Fabric
I tested with it, whether there is data from the Source or not, it still goes to "On Success".
What I need is when there is no data from the Source, it should go to "On fail".
Can anyone quickly confirm this?
Thanks.
Hi tan_thiamhuat,
start by configuring a Get Metadata activity. Use a dataset that points to your SFTP server, and apply a wildcard path such as customer_*.csv to target the expected files. In the field list of the activity, select Child Items.
After setting up the metadata check, insert an If Condition activity named "If No File". Use the expression @equals(length(activity('Get Metadata - Customer File').output.childItems), 0) to evaluate whether any files were returned. If the result is true (i.e., no files found), route the pipeline to a Fail activity with an appropriate error message like "No customer files found in SFTP. Failing pipeline." If files are found (false path), the pipeline proceeds to a Copy Activity, where it transfers the files to the destination as per your data flow logic.
Thanks,
Prashanth Are
MS Fabric community support
3 Replies
- v-prasareCommunity Support
Hi tan_thiamhuat,
No, Copy Activity does not fail by default on no data. This is by design Copy Activity does not fail when it copies zero rows. to make it as you intended, you use a pre-check with a Lookup activity to detect empty source and an If Condition to either proceed or fail. This ensures the Copy Activity only runs when there is data, and you explicitly route the pipeline to fail when the source is empty.
Thanks,
Prashanth Are
MS Fabric community support
If this my response resolves your issue, please mark it as "Accept as solution" and give kudos if you found it helpful.
- tan_thiamhuatPost Patron
are you able to do some printscreen to illustrate? How do we detect if there is a file in the SFTP Server?
- v-prasareCommunity Support
Hi tan_thiamhuat,
start by configuring a Get Metadata activity. Use a dataset that points to your SFTP server, and apply a wildcard path such as customer_*.csv to target the expected files. In the field list of the activity, select Child Items.
After setting up the metadata check, insert an If Condition activity named "If No File". Use the expression @equals(length(activity('Get Metadata - Customer File').output.childItems), 0) to evaluate whether any files were returned. If the result is true (i.e., no files found), route the pipeline to a Fail activity with an appropriate error message like "No customer files found in SFTP. Failing pipeline." If files are found (false path), the pipeline proceeds to a Copy Activity, where it transfers the files to the destination as per your data flow logic.
Thanks,
Prashanth Are
MS Fabric community support