Making ADF Web activity synchronous with Logic App

3359

Prologue

It is a common scenario in ETL jobs to send Email Notifications. With Azure Data Factory, such an example can be found in this article. Accordingly, we use web activity in the Azure Data Factory to invoke a Logic App, which in turn sends out an email. However, the former has one drawback i.e. it does not wait for a callback to be invoked, thus making it asynchronous. In order to overcome this, we can use a webhook activity in the Azure Data Factory. A demonstration of webhook activity can be found in this article.

However, we can find a way to dodge the webhook activity by using the HTTP request-response concept. This setup will make the web activity wait for an HTTP response, synchronizing it with the Logic App. Let us delve straight into the demonstration.

Azure Data Factory Web Activity

The Azure Data Factory web activity takes these parameters:

  • URL: The static URL of Logic App, which will send an Email.
  • Method: The HTTP method to be used. We will use the POST method to send a post request.
  • Headers: We need to set the Content-Type as application/json.
  • Body: Finally, we define a request body. We will send a blank request body in this demonstration.

Setting the Logic App

We all know that a Logic App runs on a trigger. In our case, the trigger is an HTTP POST request. If we want to keep the web activity asynchronous with the logic app, the below design of Logic App would suffice.

However, in order to make the web activity synchronous with the logic app, we need to tweak the latter. As mentioned in the prologue, we will use the request-response concept. Accordingly, we will add an HTTP response to the above Logic App.

Here it is interesting to note that, we have added two responses viz. Failure Response and Success Response. The former is triggered when the previous action i.e. Send an email fails while the latter is triggered to the contrary. We will demonstrate the latter case in order to end the article on a positive note 😉

However, in the first place, an important point needs consideration i.e. configuring failure response. Normally, every subsequent action in a logic app is triggered after the success of the previous one. However, we can configure it for failure as well i.e. the subsequent action is triggered at the failure of the previous one. This helps us send a customized failure message as a part of the response. Below snip shows the failure response configuration. Click on the three dots and select ‘Configure run after’.

Select ‘has failed’ in order to ensure that Failure Response is triggered only after the Send an email action fails.

In conclusion, let us go ahead and trigger the pipeline which triggers the Logic App.

The below snippet shows a successful Logic App run.

Conclusion

We hope that you find this article useful. However, we encourage you to try it out. Please note that this article is for information purposes only and we do not make any warranties.



I am a Data Scientist with 6+ years of experience.


Leave a Reply