The issue with the on-fail activity

Eddy Tran 40 Reputation points
2024-07-29T08:15:54.2433333+00:00

Dear Mr/Ms,

I created a pipeline, there is a If Condition Activity in the pipeline as below:
User's image

The content in the If Conditioin is as below: User's image

In If Condition, I set up the pipeline, if any activities failed, the next step is updating by Store procedure.

Get back to the first image, you can see, the activity Upsert tables Assets Hub is failed but there is no Store procedure running after the failure. I want to ask the reason why the store procedures updating failed status are not running in this case?

Many thanks!

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
10,690 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Amira Bedhiafi 24,556 Reputation points
    2024-08-15T21:31:00.5133333+00:00

    Based on what @Chandra Boorla provided, I will try to detail the solution.

    I am marking this question as a duplicate.

    You need to create an SP to handle different types of failures (, "Copy Failure" and "Stored Procedure Failure") where you add a parameter to accept the type of failure.

    
     CREATE PROCEDURE HandleFailure
    
         @FailureType NVARCHAR(50)
    
     AS
    
     BEGIN
    
         IF @FailureType = 'Copy Failure'
    
         BEGIN
    
             -- Add your logic to handle Copy Failure
    
             PRINT 'Handling Copy Failure';
    
         END
    
         ELSE IF @FailureType = 'Stored Procedure Failure'
    
         BEGIN
    
             -- Add your logic to handle Stored Procedure Failure
    
             PRINT 'Handling Stored Procedure Failure';
    
         END
    
         ELSE
    
         BEGIN
    
             PRINT 'Unknown Failure Type';
    
         END
    
     END
    
    

    You have multiple failure paths (Path 1, Path 2, Path 3, and Path 4) in your ADF pipeline.

    For each failure path, set up a parameter that indicates the type of failure.

    • For Path 1 and Path 3 (handling failures related to Copy activity), pass a failure type parameter indicating "Copy Failure".
    • For Path 2 and Path 4 (handling failures related to Stored Procedure activity), pass a failure type parameter indicating "Stored Procedure Failure".

    In the pipeline designer, add a Set Variable or Execute Stored Procedure activity after the failure paths and pass a literal value to a parameter indicating the type of failure ("Copy Failure" or "Stored Procedure Failure").

    
     {
    
         "type": "ExecuteStoredProcedure",
    
         "typeProperties": {
    
             "storedProcedureName": "HandleFailure",
    
             "storedProcedureParameters": {
    
                 "FailureType": {
    
                     "value": "Copy Failure",
    
                     "type": "String"
    
                 }
    
             }
    
         }
    
     }
    
    

    Instead of handling failures separately in multiple places, you can use a single Execute Stored Procedure activity to call your failure handling stored procedure where you read the failure type parameter passed from each failure path and decide which part of the stored procedure logic to execute.

    After any activity that can fail (like a Copy activity or another stored procedure), use an If Condition or directly pass the failure type parameter to your failure handling stored procedure.

    
     {
    
         "name": "FailureHandlingPipeline",
    
         "activities": [
    
             {
    
                 "name": "CopyActivity",
    
                 "type": "Copy"
    
                 // Other Copy activity settings
    
             },
    
             {
    
                 "name": "ExecuteFailureHandler",
    
                 "type": "ExecuteStoredProcedure",
    
                 "dependsOn": [
    
                     {
    
                         "activity": "CopyActivity",
    
                         "dependencyConditions": ["Failed"]
    
                     }
    
                 ],
    
                 "typeProperties": {
    
                     "storedProcedureName": "HandleFailure",
    
                     "storedProcedureParameters": {
    
                         "FailureType": {
    
                             "value": "Copy Failure",
    
                             "type": "String"
    
                         }
    
                     }
    
                 }
    
             }
    
         ]
    
     }
    
    
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.