Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
PhilPrentiss
Frequent Visitor

How to use variable-library values in a notebook

Within a notebook I would like to retrieve an active variable value from a variable-libary.  It is clear how to update the parameter from a Data Pipeline (as depicted below), but I cannot find a python package and method to do this independently in the notebook.

 

No problem updating parameter from a Data Pipeline

PhilPrentiss_2-1745848025868.png

PhilPrentiss_1-1745847819235.png

But I would like to do something like this:

PhilPrentiss_3-1745848326128.png

 

PS: I have seen the REST API method and will use that if necesssary Items - Get Variable Library - REST API (VariableLibrary) | Microsoft Learn

2 ACCEPTED SOLUTIONS
Element115
Super User
Super User

In your Notebook, declare the parameter like this (example in PySpark):

dbutils.widgets.text("my_param", "")
my_param_value = dbutils.widgets.get("my_param")
print(f"The pipeline library variable is: {my_param_value}")

 

or in regular Python cell if not using Spark:

import sys

# Parameters are usually passed as command line args after the script name
# e.g., sys.argv[1], sys.argv[2], etc.
print("Notebook parameters:", sys.argv)

 

View solution in original post

Hi @PhilPrentiss ,

 

As of now, the new Microsoft Fabric Variable Libraries do not support direct access from notebooks. This means you cannot retrieve variable values directly using Python code or a built-in SDK method inside a standalone notebook.

The current supported usage is within Data Pipelines, where you can reference variables from the variable library and then pass them as parameters into a notebook activity. Inside the notebook, you can access those parameters using methods like dbutils.widgets.get() in PySpark or sys.argv in standard Python.

So, while a direct method like get_variable() may seem logical, it isn’t available yet. The only reliable workaround is to use a pipeline to pass variable values into your notebook. Microsoft may add direct notebook support in future updates, but for now, this pipeline-based method is the correct and supported approach.

 

If this solution worked for you, kindly mark it as Accept as Solution and feel free to give a Kudos, it would be much appreciated!

 

Thank you.

View solution in original post

3 REPLIES 3
Element115
Super User
Super User

In your Notebook, declare the parameter like this (example in PySpark):

dbutils.widgets.text("my_param", "")
my_param_value = dbutils.widgets.get("my_param")
print(f"The pipeline library variable is: {my_param_value}")

 

or in regular Python cell if not using Spark:

import sys

# Parameters are usually passed as command line args after the script name
# e.g., sys.argv[1], sys.argv[2], etc.
print("Notebook parameters:", sys.argv)

 

I'm looking for a solution specific to the new fabric variable libraries

Hi @PhilPrentiss ,

 

As of now, the new Microsoft Fabric Variable Libraries do not support direct access from notebooks. This means you cannot retrieve variable values directly using Python code or a built-in SDK method inside a standalone notebook.

The current supported usage is within Data Pipelines, where you can reference variables from the variable library and then pass them as parameters into a notebook activity. Inside the notebook, you can access those parameters using methods like dbutils.widgets.get() in PySpark or sys.argv in standard Python.

So, while a direct method like get_variable() may seem logical, it isn’t available yet. The only reliable workaround is to use a pipeline to pass variable values into your notebook. Microsoft may add direct notebook support in future updates, but for now, this pipeline-based method is the correct and supported approach.

 

If this solution worked for you, kindly mark it as Accept as Solution and feel free to give a Kudos, it would be much appreciated!

 

Thank you.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June FBC25 Carousel

Fabric Monthly Update - June 2025

Check out the June 2025 Fabric update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors