Notebook source control and deployment
This article explains how Git integration and deployment pipelines work for notebooks in Microsoft Fabric. Learn how to set up a connection to your repository, manage your notebooks, and deploy them across different environments.
Notebook Git integration
Fabric notebooks offer Git integration for source control with Azure DevOps. With Git integration, you can back up and version your notebook, revert to previous stages as needed, collaborate or work alone using Git branches, and manage your notebook content lifecycle entirely within Fabric.
Important
This feature is in preview.
Set up a connection
From your workspace settings, you can easily set up a connection to your repo to commit and sync changes. To set up the connection, see Get started with Git integration. Once connected, your items, including notebooks, appear in the Source control panel.
After you successfully commit the notebook instances to the Git repo, you see the notebook folder structure in the repo.
You can now execute future operations, like Create pull request.
Notebook representation in Git
The following image is an example of the file structure of each notebook item in the repo:
When you commit the notebook item to the Git repo, the notebook code is converted to a source code format, instead of a standard .ipynb file. For example, a PySpark notebook converts to a notebook-content.py file. This approach allows for easier code reviews using built-in diff features.
In the item content source file, metadata (including the default lakehouse and attached environment), markdown cells, and code cells are preserved and distinguished. This approach supports a precise recovery when you sync back to a Fabric workspace.
Notebook cell output isn't included when syncing to Git.
Note
- Currently, files in Notebook resources aren't committed to the repo. Committing these files is supported in an upcoming release.
- The attached environment persists in a notebook when you sync from repo to a Fabric workspace. Currently, cross-workspace reference environments aren't supported. You must manually attach to a new environment or workspace default settings in to run the notebook.
- The default lakehouse ID persists in the notebook when you sync from the repo to a Fabric workspace. If you commit a notebook with the default lakehouse, you must refer a newly created lakehouse item manually. For more information, see Lakehouse Git integration.
Notebook in deployment pipelines
You can also use Deployment pipeline to deploy your notebook code across different environments, such as development, test, and production. This feature can enable you to streamline your development process, ensure quality and consistency, and reduce manual errors with lightweight low-code operations. You can also use deployment rules to customize the behavior of your notebooks when they're deployed, such as changing the default lakehouse of a notebook.
Important
This feature is in preview.
Use the following steps to complete your notebook deployment using the deployment pipeline.
Create a new deployment pipeline or open an existing deployment pipeline. (For more information, see Get started with deployment pipelines.)
Assign workspaces to different stages according to your deployment goals.
Select, view, and compare items including notebooks between different stages, as shown in the following example.
Select Deploy to deploy your notebooks across the Development, Test, and Production stages.
(Optional.) You can select Deployment rules to create deployment rules for a deployment process. Deployment rules entry is on the target stage for a deployment process.
Fabric supports parameterizing the default lakehouse for each notebook instance when deploying with deployment rules. Three options are available to specify the target default lakehouse: Same with source lakehouse, N/A(no default lakehouse), and other lakehouse.
You can achieve secured data isolation by setting up this rule. Your notebook's default lakehouse is replaced by the one you specified as target during deployment.
Note
When you choose to adopt other lakehouses in the target environment, Lakehouse ID is a must have. You can find the ID of a lakehouse from the lakehouse URL link.
Monitor the deployment status from Deployment history.