Hello @Aditya Singh
You can achieve this by using the If Condition activity and Set Variable activity in your pipeline. Here are the steps:
- Add an If Condition activity to your pipeline and set its expression to check if the activity has failed. You can use the dynamic expression
@activity('activityName').output.status
to check the status of the activity. If the activity has failed, the expression will return 'Failed', otherwise it will return 'Succeeded'.
- Inside the If Condition activity, add a Set Variable activity to set the value of the STATUS variable. If the activity has failed, set the value of the variable to 'Fail', otherwise set it to 'Success'. You can use the dynamic expression
if(equals(activity('activityName').output.status, 'Failed'), 'Fail', 'Success')
to set the value of the variable. Here is an example of what your pipeline might look like:
{
"name": "examplePipeline",
"properties": {
"activities": [
{
"name": "exampleActivity",
"type": "Copy",
"inputs": [
{
"referenceName": "exampleInputDataset",
"type": "DatasetReference"
}
],
"outputs": [
{
"referenceName": "exampleOutputDataset",
"type": "DatasetReference"
}
],
"typeProperties": {
"source": {
"type": "BlobSource"
},
"sink": {
"type": "BlobSink"
}
}
},
{
"name": "setStatusVariable",
"type": "SetVariable",
"dependsOn": [
{
"activity": "exampleActivity",
"dependencyConditions": [
"Succeeded",
"Failed"
]
}
],
"typeProperties": {
"variableName": "STATUS",
"value": {
"value": "@if(equals(activity('exampleActivity').output.status, 'Failed'), 'Fail', 'Success')",
"type": "Expression"
}
}
}
],
"variables": {
"STATUS": {
"type": "String",
"defaultValue": "Success"
}
},
"annotations": []
}
}
- In this example, the pipeline has two activities: the exampleActivity and the setStatusVariable activity. The setStatusVariable activity depends on the exampleActivity
I hope that this response has addressed your query and helped you overcome your challenges. If so, please mark this response as Answered. This will not only acknowledge our efforts, but also assist other community members who may be looking for similar solutions.