This post walks through how to access a variable library in a notebook in Microsoft Fabric. I recommend a Microsoft Fabric project starts by creating a variable library to store the common values different artifacts need and could be changed if a deployment pipeline gets involved. So when we create a notebook we need to be able to use these variables. This means we need load the variable library in a notebook and then get the variable values.
Variable Library Series
Variable libraries should be part of every project. This post is part of my series to help get you started creating the library and then using the variables and finally seeing your hard work pay back when it comes to deployment pipelines.
- Getting started with variable libraries
- Variable Values in a Fabric Notebook
- Variable Values in a Data Pipeline
- Variable Values in Lakehouse Shortcuts
- Variable Values in Dataflows
- Variable Libraries in Deployment Pipelines
- Create a Variable Library using a Python Notebook
Connect to Library
The first task is to create a variable for the variable library. The notebookutils package includes the functions we need to do this easily. In the code below the variable vl will refer to the variable library that is called “Finance Variables”. This code assumes the notebook is in the same workspace as the library.
| |
Get Variable Value
Once we have the variable library loaded, we can access the variable values in one of two syntaxes.
| |
Combining both of the two and adding some print statements we can demo the above using this code.
| |
And here is the run

Get a variable value by reference
There is a third way to get a variable value. The get method from notebookutils variable library uses a reference string that follows the following syntax:
| |
Before you get excited that the ** implies you could refer to another workspace, sorry that is not supported. This string is used in the variableLibrary.get action in notebookutils. For example to get the two values from before could be done like this
| |
And here is the run

TipThe print(f"{Limit=}") prints Limit=4 for us newbies to Python!
Naming Conventions
When you start and there are only 4 variables in the library its easy to remember the names to type in by hand when you are using a variable library in a notebook. When it gets to 20 names, its harder. So create standards, whats the case pattern, you using _ between words or not? Pick a set of rules and stick with it, BronzeWorkspaceID works just as well as Bronze_Workspace_ID, WorkspaceID1 and workspace_id2 are a technical debt you don’t need.
Conclusion on using Variable Library in a Notebook
I’m really impressed on how easy it is to use the variable library in a notebook. The pattern is simple and resusable. If I had a magic wand it it would be great is the intellisense knew the variable names from loading the variable library object.
The method by reference is great if you want to dynamically select which variable to load as the string could be dynamically built.
Using a combination of parameters and accessing a variable library means reusable notebooks are easier to write. This needs to become part of the best practice pattern being used.
References
Microsoft learn covers Variable library utilities as part of the notebook utilities page.
