How to parametrize Email ID while sending notifications using ADF

Lakshmi Narayana Sarma Bhamidipati 110 Reputation points
2024-11-19T11:53:58.6433333+00:00

Hi, We are sending email notifications while executing the ADF pipelines for success and failures. At multiple activities, we are using these Emails. How to parametrize Email ID while sending notifications using ADF? Thanks.

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
10,914 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Smaran Thoomu 17,520 Reputation points Microsoft Vendor
    2024-11-19T18:08:21.2966667+00:00

    Hi @Lakshmi Narayana Sarma Bhamidipati
    Welcome to Microsoft Q&A platform and thanks for posting your query here.
    To help you send notifications with parameterized email IDs in Azure Data Factory (ADF) pipelines, here's a simple explanation:

    Create a Pipeline Parameter for the Email:

    • Inside your ADF pipeline, create a parameter (e.g., EmailRecipient). This will store the email address you want to use for notifications.

    Pass the Parameter to the Email Activity:

    • If you're using a Web Activity to send emails, you can reference the parameter in the request body or headers using @pipeline().parameters.EmailRecipient. This makes the email address dynamic, instead of hardcoding it.
    • Alternatively, you can use an Azure Logic App triggered from ADF and pass the parameter value to the Logic App, which then handles the email notification.

    Set Parameter Values Dynamically:

    • You can dynamically set the parameter value during pipeline execution using variables or derived values based on specific conditions. For example, you might have a lookup activity to fetch email addresses from a table and set this value through subsequent activities.

    Use Parameters in Multiple Activities:

    • Since parameters are reusable, you can use the same parameter (EmailRecipient) across different activities within the pipeline. This avoids hardcoding and enables easy updates if the recipient list changes.

    Example expression for using a parameter:

    {
        "emailTo": "@pipeline().parameters.EmailRecipient",
        "subject": "Pipeline Status Notification",
        "message": "The pipeline run has completed."
    }
    

    Reference: Send an email with an Azure Data Factory or Azure Synapse pipeline

    Video link: https://www.youtube.com/watch?v=yw-_txuwUiA

    I hope this helps. If you have any further questions, please let me know.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.