data factory if condition false, exit pipeline execution

a1990 11 Reputation points
2021-12-22T17:05:29.133+00:00

In if component under false condition , how to exit from pipeline execution? Through Getmetadata component, i am search the file and if it's true, it has to progress with rest of pipeline and under false i.e no file available it has exist/stop pipeline execution graceful has successful execution rather than fail pipeline status.

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
9,805 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Nandan Hegde 29,911 Reputation points MVP
    2021-12-23T05:21:09.683+00:00

    Hey,
    There are 2 ways which I can think of:

    1. Ideally a bad design but would guarantee no failed activities and successful pipeline status :

    have the logics outside the IF activity within another pipeline and within the true condition of If activity call the pipeline via Execute pipeline activity. In case if file is not present it would go to false part and since there are no activities outside IF activity, the pipeline is completed.

    2) Based on some additional activities, it would ensure your pipeline status is success

    For understanding the logic, refer this blog last section :
    https://datasharkx.wordpress.com/2021/08/19/error-logging-and-the-art-of-avoiding-redundant-activities-in-azure-data-factory/

    code:

    {  
        "name": "pipeline1",  
        "properties": {  
            "activities": [  
                {  
                    "name": "If Condition1",  
                    "type": "IfCondition",  
                    "dependsOn": [],  
                    "userProperties": [],  
                    "typeProperties": {  
                        "expression": {  
                            "value": "@equals(pipeline().parameters.Test,'1')",  
                            "type": "Expression"  
                        },  
                        "ifFalseActivities": [  
                            {  
                                "name": "Fail2",  
                                "type": "Fail",  
                                "dependsOn": [],  
                                "userProperties": [],  
                                "typeProperties": {  
                                    "message": "No file",  
                                    "errorCode": "2"  
                                }  
                            }  
                        ],  
                        "ifTrueActivities": [  
                            {  
                                "name": "Wait3",  
                                "type": "Wait",  
                                "dependsOn": [],  
                                "userProperties": [],  
                                "typeProperties": {  
                                    "waitTimeInSeconds": 1  
                                }  
                            }  
                        ]  
                    }  
                },  
                {  
                    "name": "Wait1",  
                    "type": "Wait",  
                    "dependsOn": [  
                        {  
                            "activity": "Wait2",  
                            "dependencyConditions": [  
                                "Skipped"  
                            ]  
                        }  
                    ],  
                    "userProperties": [],  
                    "typeProperties": {  
                        "waitTimeInSeconds": 1  
                    }  
                },  
                {  
                    "name": "Wait2",  
                    "type": "Wait",  
                    "dependsOn": [  
                        {  
                            "activity": "If Condition1",  
                            "dependencyConditions": [  
                                "Failed"  
                            ]  
                        }  
                    ],  
                    "userProperties": [],  
                    "typeProperties": {  
                        "waitTimeInSeconds": 1  
                    }  
                }  
            ],  
            "parameters": {  
                "Test": {  
                    "type": "string",  
                    "defaultValue": "1"  
                }  
            },  
            "annotations": [],  
            "lastPublishTime": "2021-12-23T04:20:07Z"  
        },  
        "type": "Microsoft.DataFactory/factories/pipelines"  
    }  
    

    159896-image.png

    1 person found this answer helpful.

  2. a1990 11 Reputation points
    2021-12-22T17:18:24.313+00:00

    Also i tired with fail component, it able to exit but the job status showing as failed. In failed status, automatically it'll raise the incident, so looking for graceful exit with out failed job message.

    0 comments No comments

  3. a1990 11 Reputation points
    2021-12-24T10:22:30.24+00:00

    Thanks for reply. Check out attached screenshot, still given solution is flagging the red failed status in the job.. I need a graceful exit with green status - succeeded. My scenario is, need to pull the files on regular interval from sftp(sometime it won't on arrive ontime) in that scenarios it has ignore and exit with green status - succeeded

    As i mentioned failed activity will raise the operation incident which we are trying to avoid it.

    ![160329-image.png]1