Skip to content
Carmel Eve By Carmel Eve Software Engineer II · 3 min read
Microsoft Fabric variable libraries: best practices guide

At SQLBits 2026, I attended a session by Kevin Arnold on variable libraries in Microsoft Fabric. It was originally a 20-minute slot, but they let him continue into the break and he ended up speaking for around 45 minutes - which was a good thing, as there was plenty of ground to cover. Variable libraries are one of those features that seems straightforward on the surface, but getting the details right really matters - especially when it comes to protecting your production environment.

This post covers what variable libraries are, where you can use them, and some best practices that came out of the session (along with some thoughts of my own).

What Are Variable Libraries?

Variable libraries are Microsoft Fabric's intended mechanism for managing environment-specific configuration. If you've worked with configuration management in software development, this will feel familiar - think appsettings per environment, but for Fabric items.

The basic concept is:

  1. You define a set of variables with default values
  2. You then create a variable set for each environment (e.g. Dev, Test, Prod)
  3. Each variable set needs to be "activated" for the environment it's deployed to
Microsoft Fabric Weekly is a summary of the week's top news to help you build on the Microsoft Fabric Platform.

The variable values are all stored in Git, which means they're updated as part of your deployment process. However - and this is important - which variable set is activated for each environment is a separate concern. If you're using Fabric deployment pipelines, you can configure a different active value set per stage, which helps. But it's still worth being aware that activation and deployment are distinct steps, and getting them out of sync is a real risk.

Diagram showing variable libraries with Default, Dev, Test, Prod sets

Where Can You Use Them?

Variable libraries can be used across a range of Fabric item types:

  • Lakehouse shortcuts - allowing your shortcuts to point to different storage locations per environment
  • Notebooks - either directly with %%configure (including setting the default lakehouse) or via notebookutils
  • Data pipelines - for parameterising pipeline activities
  • Dataflow Gen2 - support has been expanding here, with integration via Variable.Value and Variable.ValueOrDefault functions in M code
  • Copy jobs - as source or destination
  • User Defined Functions

It's worth noting that the variable values themselves are just stored as part of the Git-tracked configuration, so they can't contain secrets or sensitive information. For secrets, you'd still need to use a solution like Azure Key Vault.

A Best Practice: Don't Map Defaults to Real Environments

One of the most interesting takeaways from this session was around how you structure your variable sets. The presenter's setup had four sets: Default, Dev, Test, and Prod - where the Default set had clearly non-functional placeholder values.

This is in contrast to a pattern where you might map Default directly to your Dev environment, like: Default (= Dev), Test, Prod.

The problem with the latter approach is subtle but significant. If you deploy to an environment and the correct variable set hasn't been activated (or if activation is accidentally skipped), your Fabric items will fall back to the Default values. If Default points to Dev, you could accidentally end up reading from or writing to your Dev environment from a workspace that's supposed to be pointing elsewhere.

However, if your Default values are clearly non-functional placeholders (e.g. a connection string pointing to a non-existent lakehouse), then a missed activation would result in an obvious failure rather than a silent cross-environment issue. Failing loudly is almost always better than failing silently, especially when data integrity is at stake.

The best hour you can spend to refine your own data strategy and leverage the latest capabilities on Azure to accelerate your road map.

Of course, the ideal solution is to properly isolate your workspaces so that cross-environment writes aren't possible in the first place. But adopting the "non-functional default" pattern as an additional safety net is a simple and effective precaution.

Things to Watch Out For

There are a few additional things to be aware of:

SharePoint shortcuts can't currently use variable libraries. This is a notable limitation if you're working with SharePoint data across multiple environments. It's likely coming in a future update, but for now, it means you may need an alternative approach for environment-specific SharePoint integration.

Activation needs attention. While deployment pipelines do support configuring a different active value set per stage, the activation step is still separate from the deployment itself. Building in validation steps (e.g. checking which variable set is active as part of your deployment verification) would help mitigate the risk of things getting out of sync.

Git storage means no secrets. As mentioned, variable values are stored in Git, so anything sensitive needs to be managed separately. Combining variable libraries with Azure Key Vault is a good pattern for handling this.

Summary

Variable libraries are a welcome addition to the Fabric CI/CD story, providing a structured way to manage environment-specific configuration across a range of Fabric items. The key things to remember are: use non-functional default values as a safety net, be aware that activation is a manual step, and combine with Key Vault for any secrets.

I'll be keeping an eye on how this feature evolves - particularly around automation of the activation step and expanded support for item types like SharePoint shortcuts.

FAQs

What are variable libraries in Microsoft Fabric? Variable libraries are the intended mechanism for managing environment-specific configuration in Fabric. You define a set of variables with default values, then create a variable set for each environment (e.g. Dev, Test, Prod), which needs to be 'activated' for each environment.
Where can you use variable libraries in Microsoft Fabric? Variable libraries can be used in lakehouse shortcuts, notebooks (via %%configure or notebookutils), data pipelines, Dataflow Gen2 (CI/CD flows, in the M code only), copy jobs (as source or destination), and user defined functions.
What is a best practice for default variable values in Fabric? A recommended best practice is to set default variable values to clearly non-functional placeholder values, rather than mapping defaults to any real environment. This prevents accidental writes to the wrong environment if the correct variable set hasn't been activated.

Carmel Eve

Software Engineer II

Carmel Eve

Carmel is a software engineer and LinkedIn Learning instructor. She worked at endjin from 2016 to 2021, focused on delivering cloud-first solutions to a variety of problems. These included highly performant serverless architectures, web applications, reporting and insight pipelines, and data analytics engines. After a three-year career break spent travelling around the world, she rejoined endjin in 2024.

Carmel has written many blog posts covering a huge range of topics, including deconstructing Rx operators, agile estimation and planning and mental well-being and managing remote working.

Carmel has released two courses on LinkedIn Learning - one on the Az-204 exam (developing solutions for Microsoft Azure) and one on Azure Data Lake. She has also spoken at NDC, APISpecs, and SQLBits, covering a range of topics from reactive big-data processing to secure Azure architectures.

She is passionate about diversity and inclusivity in tech. She spent two years as a STEM ambassador in her local community and taking part in a local mentorship scheme. Through this work she hopes to be a part of positive change in the industry.

Carmel won "Apprentice Engineer of the Year" at the Computing Rising Star Awards 2019.