0

If until activity skipped after 5 mins. I need to send a mail.

How to send the message from until to email notification pipeline. 

Email notification have message as a parameter. What is the correct Syntax if pipeline skipped 

<p>Hi All,<\/p>\r\n<p>Below pipeline got failed please find the error details.<\/p><br \/>\r\n<p>Pipeline Name : @{pipeline().Pipeline}<\/p>\r\n<p>Error Detail : <br\/>@{activity('LKP_INF_JOB_STATUS').output.error.message}<\/p>\r\n<p>&nbsp;<\/p>\r\n<p>Thanks,<br\/>SPC Support Team<\/p>\r\n<p>&nbsp;<\/p>\r\n<p><br \/>Note:This is an auto-generated email from XYZ, please do not reply directly to this email.<\/p>


[![enter image description here][1]][1]


  [1]: https://i.stack.imgur.com/yUtUQ.png
anuj
  • 124
  • 2
  • 13
  • We are unable to see the screenshot you tried to attach as it is included as code snippet – Trent Tamura Jul 20 '21 at 18:23
  • Need more information and details on what exactly you are trying to do – Trent Tamura Jul 20 '21 at 18:38
  • Hi Trent not sure why image is not visible. But idea is that I have until activity & it is running 10 mins after 10 mins it will skip so when untill is skip i need to send a mail using web activity. UNTILL-->Notification mail. Like when ever any activity is failing we are sending mail by expression error. message. Similar when any activity skipped I need to send a mail like UNTILL activity is skipped for a given time. – anuj Jul 21 '21 at 06:09
  • Okay I believe it’s possible. I will post with example later today. – Trent Tamura Jul 21 '21 at 11:58

1 Answers1

0

I implemented a simple solution for this:

1. Give your Until Activity a specific timeout

Until Activity

2. Create a Web Activity that uses the ADF API to query the Until Activity using a Completion dependency (blue arrow)

Refer to this Stack Overflow for details on how to use this API in ADF: How to get output parameter from Executed Pipeline in ADF?

API Web Activity to get Activity status

URL: https://management.azure.com/subscriptions/@{pipeline().parameters.SubscriptionId}/resourceGroups/@{pipeline().parameters.ResourceGroupName}/providers/Microsoft.DataFactory/factories/@{pipeline().DataFactory}/pipelineruns/@{pipeline().RunId}/queryActivityruns?api-version=2018-06-01

Body:

{
  "lastUpdatedAfter": "2018-06-16T00:36:44.3345758Z",
  "lastUpdatedBefore": "@{utcnow()}",
  "filters": [
    {
      "operand": "ActivityName",
      "operator": "Equals",
      "values": [
        "Until Timeout after 1 min"
      ]
    }
  ]
}

3. Use output from activity in Switch to determine which Email Activity to use (Failure, or TimeOut)

Switch Activity

Expression:

@activity('Check Until Activity Status').output.value[0].status

4. Email Activity

Email Activity

{
  "personalizations": [
    {
      "to": [
        {
          "email": "YourEmail@blah.com",
          "name": "blah"
        }
      ],
      "cc": [
        {
          "email": "jane_doe@example.com",
          "name": "Jane Doe"
        }
      ],
      "bcc": [
        {
          "email": "james_doe@example.com",
          "name": "Jim Doe"
        }
      ]
    }
  ],
  "from": {
    "email": "blah@example.com",
    "name": "Blah"
  },

  "subject": "SkipEmail",
  "content": [
    {
      "type": "text/html",
      "value": "This is a Skip Example, put whatever here"
    }
  ]


}
halfer
  • 19,824
  • 17
  • 99
  • 186
Trent Tamura
  • 1,079
  • 6
  • 16