azureazure-pipelinesazure-synapseazure-notebooks

Is there a way for notebooks in synapse to take in pipeline variables?


new to this and apologise for any frustrations.

I am developing a notebook which can handle api requests however I want to use one notebook which can intake the pipeline variables so the same notebook can be used again for a different set of pipeline variables. I don't know what packages or syntax to use for this case.

I tried searching for it online but not finding any real answers, any direction will be appreciated.

A look of the pipeline


Solution

  • To pass a variable from the pipeline to the Notebook, first you need to initialize the parameter in the notebook by enabling the Toggle parameter cell in the notebook cell. Now, initialize the parameter with any value.

    enter image description here

    Currently, synapse notebook activity only supports string, int, float and bool types. To pass the array variable from the pipeline, pass it as string and convert it into array in the python code using eval() function.

    Pass the variable with expression @string(<variable_name>). For sample, I have passed it like below.

    enter image description here

    In the notebook, use the eval() after initializing the parameter.

    a=eval(param1)
    print(a)
    

    Now, debug the pipeline and you can see the parameter of desired type was passed to the notebook.

    enter image description here