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
andPath 3
(handling failures related to Copy activity), pass a failure type parameter indicating"Copy Failure"
. - For
Path 2
andPath 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"
}
}
}
}
]
}