Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
russellhq
Regular Visitor

How To Exit Pipeline Successfully On Condition

Hi, I'm new to pipelines and have been trying to find out how to control the flow of a pipline so it can exit succesfully if a condition is met.


The pipeline is on a schedule, each time it runs, it looks for files in a folder, if there are files there it continues with the rest of the activities, if not it should exit succesfully. I've tried using an If activity, but I can only get that to work if put a Fail activity in it. But this then shows up in the logs as the pipline failed which then needs checked.


Is there a way to get a pipeline to exit sucessfully if a condition is met so it doesn't run the rest of the activites?

1 ACCEPTED SOLUTION

Thanks Ben, I've got something like this set up and working. The issue is I can't add all my activities into the if activity as some of them are for loops and more if activites as well which aren't supported within an if activity.

 

I've reworked the pipeline to remove the loops and if conditions from within the if block and have got things working now. I've also started using pipeline return parameters which has helped as well.


View solution in original post

5 REPLIES 5
benfedit
Advocate I
Advocate I

hi @russellhq ,

You can add a set variable activity after the getmetadata and use this variable in the if condition activity.

The variable can be a boolean type and you can use exactly the function that @FabianSchut  mentioned above inside this set variable and in the if condition you use (yourvariable==true)

Ben

Thanks Ben, I've got something like this set up and working. The issue is I can't add all my activities into the if activity as some of them are for loops and more if activites as well which aren't supported within an if activity.

 

I've reworked the pipeline to remove the loops and if conditions from within the if block and have got things working now. I've also started using pipeline return parameters which has helped as well.


FabianSchut
Super User
Super User

Hi @russellhq,

 

You could use Get metadata with child items to check whether there are files in the folder at all. After your Get metadata activity, you can connect an If condition and check if there are 1 or more files in the folder. The condition for the If condition could be: @greater(length(activity('Get Metadata1').output.childItems), 0). Put all your activities in the True section of the if condition and nothing in the False section. This way, the pipeline will run succesfully without failures.

I though this would work and gave it a try. But because the actions I want to put in the IF activity are ForEach and IF activities as well, the pipeline doesn't allow them inside an IF block.

Houston-ho
Advocate I
Advocate I

i believe you should have a script or logic to count the files you want, if that is true, invoke another pipeline, else, do nothing and end the current pipeline.

Helpful resources

Announcements
Fabric July 2025 Monthly Update Carousel

Fabric Monthly Update - July 2025

Check out the July 2025 Fabric update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.