Search code examples
azure-synapseazure-notebooks

Can I get pipeline parameters in Synapse Studio Notebook dynamically without predefining parameter names in parameter cell?


In the Pipeline that triggers the Notebook, I'm passing some base parameters in, as below. enter image description here

Right now, all the materials I read instructed me to declare variables inside the Notebook parameter cell with the same names, as below. enter image description here

Is there a way that I can get the Pipeline parameters dynamically without pre-defining the variables? (Similar mechanism with sys.argv, in which a list of args are returned without the need of predefined variables)


Solution

    • To be able to pass parameters, you should have them declared in the synapse notebooks so that the values can be received and used as per requirement.

    • The closest functionality similar to sys.argv you can get is to just declare one parameter in the parameter cell.

    enter image description here

    • Now, concatenate all the values separated by a delimiter like space or ,. So that, you can just use split and use the values same as sys.argv. So, instead of creating new parameters each time, you can just concatenate the value to this parameter itself.
    @{pipeline().parameters.a} @{pipeline().parameters.b} @{pipeline().parameters.c}
    

    enter image description here

    • When I run this, the values would be passed as shown below. You can use split on args variable and then use the values accordingly.

    enter image description here