Search code examples
azure-data-factoryazure-synapse

ADF send email when there are more than one activity


I am doing all the heavy lifting in a child pipeline and in my master pipeline using the Execute Pipeline activity I'm calling the child pipeline and whatever the outcome of the underlying child pipeline email notification is sent out. But, recently there was a change in the business requirement and now I have Execute Pipeline activity -> Set variable activity -> Web. Is there a slick hack where I don't have to connect each activity to web for either success or failure.

What options are out there to accomplish my ask?

enter image description here


Solution

  • If your requirement is to send the mail for the Success or failure of the Execute pipeline activity and include other activities between Execute pipeline and web you can try the parent pipeline like below.

    enter image description here

    Use set variable activity on Completion of Execute pipeline and on Completion of the set variable activity, use the web activity. You can add any activities in between them.

    To Send the mail of whether the child pipeline is success or not, use the below expression in the web activity. First check the child pipeline status with @activity('Execute Pipeline1')?.Status in an if condition and if its a failure send the error message and if its a success send the Success mail.

    @if(equals(activity('Execute Pipeline1')?.Status,'Failed'),activity('Execute Pipeline1').error.message,'Pipeline Success')
    

    If your requirement is to send the mail for every activity success or failure in the Parent pipeline, then adding web activity for every activity is a difficult task. So, do the same for parent pipeline as what you did for child pipeline.

    Create another pipeline(parent2) with an Execute pipeline activity and give the parent pipeline(Child->parent1->parent2). After this, use web activity for sending mail.