in ADF how to use script parameters in the new script activity

Smithila Dandina 0 Reputation points
2024-10-30T14:23:59.9633333+00:00

I need to need script parameters to run a stored procedure in snowflake but the new upgraded script activity doesn't support script parameters and I need to pass them dynamically into snowflake stored procedure. Can someone please assist me with this ?

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

1 answer

Sort by: Most helpful
  1. Vinodh247 40,556 Reputation points MVP Volunteer Moderator
    2024-10-31T10:13:14.6466667+00:00

    Hi Smithila Dandina,

    Thanks for reaching out to Microsoft Q&A.

    Approach 1:

    To work around the lack of script parameter support in the new Script Activity in ADF, you can pass parameters dynamically using expressions to construct the SQL command with the desired parameters directly in the activity. Here’s a way to handle it:

    • Create a Dynamic SQL Statement: In the Script Activity, construct the SQL command by concatenating the parameter values using ADF expressions. For example

    EXECUTE PROCEDURE my_stored_procedure('${myParameter1}', '${myParameter2}')

    • Use Pipeline Variables: Define the parameters as pipeline variables (e.g., myParameter1, myParameter2). In the Script Activity, reference these parameters dynamically within your SQL script using @concat.
    • Build the Script Dynamically:
      • in the SQL statement field of the Script Activity, use the @concat expression to build the command:

        @concat('EXECUTE PROCEDURE my_stored_procedure('', pipeline().parameters.myParameter1, '', '', pipeline().parameters.myParameter2, '')')

    • Pass Parameters to Script: If these parameters are dynamically provided, ensure they are set as pipeline parameters or variables that are accessible within the Script Activity.

    Approach 2:

    You can pass parameters dynamically to your Snowflake stored procedure by using Azure Functions as an intermediary layer.

    Here's highlevel approach:

    Create an Azure Function: Set up an Azure Function that will be triggered by your ADF pipeline.

    Pass Parameters: Use the parameters from your ADF pipeline to pass them to the Azure Function.

    Call Stored Procedure: In the Azure Function, use the parameters to call your Snowflake stored procedure.

    Please feel free to click the 'Upvote' (Thumbs-up) button and 'Accept as Answer'. This helps the community by allowing others with similar queries to easily find the solution.


Your answer

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