I am using Web Activity to send notifications of pipeline run in MS Teams. My requirement is to use minimum number of web activities to reduce the cost. At the same time I want notification in case any of the activities fail. Please suggest the ideal connection keeping in mind the above requirement.
I want to use as small number of activities as possible to send notification. I tried to connect using only one web activity but it fails.
2
Answers
It will be a complex task and involves lot of activities to send the message for any of the activity failure in a pipeline.
You can use Execute pipeline activity for this requirement. But this requires another parent pipeline. Remove the web activities and put all of your required activities in a pipeline and call that pipeline from another pipeline (Parent).
Here, whenever any activity in the child pipeline fails the Execute pipeline activity will get failed and it has information about the error message and activity name.
Follow the below demo for better understanding:
For sample, I took some set variable activities in child pipeline and intentionally generating error.
Now, in the parent pipeline, call this pipeline using Execute pipeline activity and make sure you check on Wait on completion check box.
On completion of the Execute pipeline, I have added a set variable activity with variable
Chat_message
. This is the expression to get the chat message.When any of the child pipeline’s activity gets failed, the total pipeline gets failed and also the Execute pipeline activity in the parent also gets failed.
Now, on completion of this activity, the above expression, will check whether the pipeline is a failure or success and gives the message as per the status.
**Message when child pipeline gets failed: **
**Message when pipeline succeeded: **
As you want to send this message to your team, replace the set variable activity in the parent pipeline with your web activity and in the place of chat message add the above expression. Whether the pipeline is a failure or a success, it uses only single web activity to send the message.
One way as stated by Rakesh is to leverage Execute pipeline activity but that means managing an additional pipeline.
You can also manage by adding dependencies in the form of on completion, skip and validate the status of all the activities and get list of all error messages if there are any and send a common email notification.
my below blog provides a detailed framework for the same :
https://datasharkx.wordpress.com/2021/08/19/error-logging-and-the-art-of-avoiding-redundant-activities-in-azure-data-factory/