Search code examples
azureazure-logic-appsazure-databricks

Sending e-mail from Azure Databricks


We have a requirement to send e-mails from Azure Databricks in case of some conditions. We do not want to use SMTP to send e-mails.

We were planning to use Logic Apps to send the mails. Is there any way we can call a Logic App to send an e-mail in case of the condition is met.


Solution

  • Sure you can use logic apps which has multiple connectors to send the mails which include Gmail, Outlook, etc . while if you are checking whether the condition is met you can use the Condition action of the Control connector.

    enter image description here

    UPDATED ANSWER

    One of the workarounds is that you can call logic apps from Databricks notebook using REST API. Consider below is my code in data bricks notebook.

    import requests as req
    import json
    
    input_data = {'X': 1, 'Y': 2}
    url = '<YOUR_LOGICAPP_POST_REQUEST>'
    resp = req.post (url, data=json.dumps(input_data))
    print(resp.text)
    

    Below is the flow of my logic app

    enter image description here

    RESULT:

    enter image description here

    REFERENCES:

    1. Office 365 Outlook - MSFT Documentation
    2. control workflow actions - MSFT Documentation