pass a variable in synapse notebook 1 to synapse notebook 2 which are part of synapse pipelines

Suraj Tripathi 72 Reputation points Microsoft Employee
2023-04-05T05:18:54.0633333+00:00

Hi, I have a notebook where I am defining a variable "error_message", I want to read that in the next notebook. Both the notebooks are part of the synapse pipeline.

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
4,696 questions
{count} votes

1 answer

Sort by: Most helpful
  1. AnnuKumari-MSFT 32,161 Reputation points Microsoft Employee
    2023-04-06T05:17:39.9133333+00:00

    @Suraj Tripathi Thankyou for using Microsoft Q&A platform and thanks for posting your query here. You can read the value of the variable in the next notebook by using the %run magic command in the second notebook.

    You can use %run <notebook path> magic command or mssparkutils.notebook.run() to reference another notebook within current notebook's context. All the variables defined in the reference notebook are available in the current notebook.

    Example1: %run /<path>/Notebook1 { "parameterInt": 1, "parameterFloat": 2.5, "parameterBool": true, "parameterString": "abc" }. Example2: mssparkutils.notebook.run("folder/Sample1", 90, {"input": 20 }) For additional details, kindly check :

    1. Notebook reference
    2. Reference a notebook
    3. %run command to reference another notebook with in current notebook in Azure Synapse Analytics
    4. run() function of notebook module in MSSparkUtils package in Azure Synapse

    Hope it helps. Kindly accept the answer if it helps. Thankyou.