Edit

Share via


Tutorial - Local deployment with fabric-cicd

In this tutorial, you set up a basic development environment and use the fabric-cicd python library to publish a lakehouse and notebook to a Microsoft Fabric workspace that you developed locally on your dev workstation. This tutorial is an example for developers who are working locally.

Prerequisites

  • A test workspace in Microsoft Fabric
  • Admin permissions on the Fabric workspace.
  • A GitHub account (required to access demo files)
  • VS Code or similar editor: Download VS Code
  • Python Install python
  • Azure CLI (used only for authentication): Install Azure CLI

Step 1. Download the source files

  1. Fork the Fabric-cicd repository to your GitHub account.
  2. Clone your fork to your local machine:
git clone https://github.com/<your-account>/fabric-samples/tree/main/docs-samples/cicd/fabric-cicd-local.git
cd fabric-samples

Step 2. Install fabric-cicd

Using the terminal from within VS Code, install the fabric-cicd python library.

pip install fabric-cicd

Note

Fabric-cicd requires python versions 3.9 to 3.12. If you're using python 3.13 or greater, you can bypass the python requirement check with the following:

pip install fabric-cicd --ignore-requires-python

Step 3. Edit the workspace id in the deploy.py script

Navigate to the fabric-cicd-local files that you cloned down in step 1. They're located in the samples folder. Edit the deploy.py script, replacing <YOUR_WORKSPACE_ID> with your id. Save the changes.

from pathlib import Path
from fabric_cicd import FabricWorkspace, publish_all_items # 👈 import the function

repo_dir = Path(__file__).resolve().parent # ...\fabric_items

workspace = FabricWorkspace(
 workspace_id="<YOUR_WORKSPACE_ID>",
 repository_directory=str(repo_dir),
 # environment="DEV", # optional, but required if you use parameter replacement via parameter.yml
 # item_type_in_scope=["Notebook", "DataPipeline", "Environment"], # optional scope
)

publish_all_items(workspace) # 👈 call the function

Step 4. Login with az login

Using the terminal from within VS Code, sign-in using az login.

az login

Note

If you're using a trial or have no Azure subscriptions associated with your account you can use the --allow-no-subscriptions switch.

az login --allow-no-subscriptions

Screenshot of running az login in VS Code.

Step 5. Run the script

Now run the deploy.py script. From within VS Code, go to Run -> Start Debugging. You should see the following output in the screenshot.

Screenshot of running deploy.py in VS Code.

Step 6. Verify the items were created

Once the script completes, check your Fabric workspace. You should see the new lakehouse and notebook. Congrats you're done!

Screenshot of the Fabric workspace with new items.

Debugging

If an error arises, or you want to have full transparency to all calls being made outside the library, enable debugging. Enabling debugging writes all API calls to the terminal. The logs can also be found in the fabric_cicd.error.log file.

from fabric_cicd import change_log_level
change_log_level("DEBUG")

For comprehensive debugging information, including how to use the error log file and debug scripts, see the Troubleshooting Guide.