DevOps y observabilidad

Deploy a Fabric Solution with Git, Deployment Pipelines and Database Projects

A hands-on Microsoft Fabric lifecycle lab: version a workspace with Git integration, promote it from Dev to Test with a deployment pipeline and deployment rules, change a Warehouse schema as a database project, cause two controlled deployment failures and plan rollback.

Por JaviPublicado 21 min de lecturaIntermedio

Microsoft Fabric gives you three lifecycle tools that are easy to confuse: Git integration, deployment pipelines and database projects. They overlap in the portal, and all three show up whenever someone says “Fabric CI/CD”. This lab uses all three on one small solution, so you see what each one is for, what each one is not for, and what happens when they disagree.

You will connect a Dev workspace to Git, change items through commits, promote them to a Test workspace with a deployment pipeline, fix an environment-specific setting with a deployment rule, change a Warehouse schema as code, and cause two deployment failures on purpose.

The three tools

Tool What it is for What it is not for
Git integration Version control of supported item definitions in a workspace: history, branches, pull requests, revert Promoting between environments, copying data, storing secrets, workspace permissions or most settings
Deployment pipelines Promoting items from one stage workspace to the next (Dev → Test → Prod), comparing stages, applying deployment rules Version history or code review; it copies the current state of the source stage, whatever it is
Database projects Schema as code for a Warehouse: .sql files, a build that validates them into a .dacpac, a schema-aware deploy that applies only the differences Moving data, managing users and permissions, versioning non-SQL items

They meet in one place: when a Git-connected workspace contains a Warehouse, Fabric commits that Warehouse as a database project. The schema in your repository is the same project you can build and publish from Visual Studio Code.

  1. 1ChangeIn Fabric or in VS Code
  2. version
    2CommitGit repository, branch main
  3. 3BuildDatabase project → .dacpac
  4. 4Update DevWorkspace syncs from Git
  5. promote
    5Deploy to TestPipeline, compare, rules
  6. 6ValidateData, bindings, security
The lifecycle in this lab. Git holds the definitions; the deployment pipeline moves the Dev state to Test; the database project is the Warehouse part of the same repository, validated by a build before it reaches either workspace.

Prerequisites

  • Two workspaces on a trial or test capacity, where you are Admin: ws_lifecycle_dev and ws_lifecycle_test.
  • Two more small workspaces for the reference data used in Break 1: ws_lifecycle_data_dev and ws_lifecycle_data_test.
  • A Git repository you can push to, on Azure DevOps, GitHub or GitHub Enterprise (cloud), and Git integration allowed by your Fabric admin. If you have never connected a workspace, do Connect Microsoft Fabric to Git first: this lab doesn’t repeat those screens.
  • Visual Studio Code with the SQL Database Projects and SQL Server (mssql) extensions, and the .NET SDK.
  • The customers.csv file from the Lab 01 dataset.

Setup

In ws_lifecycle_dev:

  1. Create a Lakehouse lh_sales, upload customers.csv to Files/landing, and create a Warehouse wh_sales.

  2. Create a notebook nb_load_customers with lh_sales as its default Lakehouse:

    PySpark
    df = (spark.read.option("header", True).option("inferSchema", True)
          .csv("Files/landing/customers.csv"))
    df.write.mode("overwrite").saveAsTable("customers")
    print(f"loaded {df.count()} customers")
    PySpark4 líneasCelda de ejemplo de solo lectura. Nada en esta página ejecuta código.
  3. In wh_sales, create one table and load it from the Lakehouse:

    Consulta SQL: SetupT-SQL (Fabric Warehouse)
    CREATE TABLE dbo.customers AS
    SELECT customer_id, first_name, last_name, email, segment, city, [state], country
    FROM lh_sales.dbo.customers;
    T-SQL (Fabric Warehouse)3 líneasVista de solo lectura. No está conectada a ninguna base de datos.

In ws_lifecycle_data_dev and ws_lifecycle_data_test: create a Lakehouse lh_reference in each, with a one-row table that says which environment it belongs to. Run this in a notebook attached to each Lakehouse, with the right value:

spark.createDataFrame([("dev",)], ["env"]).write.mode("overwrite").saveAsTable("env_marker")
# in ws_lifecycle_data_test, use ("test",)

Step 1: Connect Dev to Git and commit

  1. In ws_lifecycle_dev, open Workspace settings → Git integration, connect to your repository, branch main, folder fabric.
  2. Open Source control and commit every item with the message initial lifecycle lab.
  3. Open the repository and look at what was stored:
In the repository What it is
nb_load_customers.Notebook/notebook-content.py The notebook as source, including its default Lakehouse in metadata; no cell output
lh_sales.Lakehouse/ Lakehouse metadata (name, shortcuts if any); no customers table, no CSV
wh_sales.Warehouse/ A database project: a .sqlproj file and one .sql file per object, including the customers table definition

Expected result: three items committed, and no data anywhere in the repository. A search for example.com should find no match: Microsoft documents that Lakehouse tables and files aren’t tracked in Git (what is tracked), and that the Warehouse is committed as a database project (Warehouse Git integration).

Step 2: Change workflow

  1. Change in Fabric. In nb_load_customers, add a cell that prints the row count by state. Commit it from Source control. Check that the commit appears in the repository history.
  2. Change in Git. In the repository, edit notebook-content.py and change the message in the print statement. Commit to main.
  3. In ws_lifecycle_dev, Source control now shows an incoming update. Select Update all, open the notebook and confirm it shows your Git change.

Expected result: the workspace and the branch are in sync in both directions. A team adds branches and pull requests on top of this; Git Integration in Microsoft Fabric: A Practical Development Workflow covers branching out, protected main and conflict resolution.

Step 3: Promote Dev to Test with a deployment pipeline

  1. Create a deployment pipeline dp_lifecycle_lab with two stages, Development and Test.
  2. Assign ws_lifecycle_dev to Development and ws_lifecycle_test to Test.
  3. Select all three items in Development and Deploy to Test.
  4. Open ws_lifecycle_test and check each item:
Item in Test Expected result
lh_sales A new, empty Lakehouse: no table, no files. Microsoft documents that deployment creates a new empty Lakehouse and never overwrites data
nb_load_customers Deployed and bound to the Test lh_sales: notebook auto-binding applies when the dependency is in the same workspace and deployed with it
wh_sales The dbo.customers table exists, with no rows: Warehouse deployments apply schema, not data
  1. Run nb_load_customers in Test. Expected result: it fails, because Files/landing is empty in the Test Lakehouse. Upload the CSV there and run it again.

Expected result: the pipeline promotes definitions, and you provide the data for the new environment yourself. That is by design: each environment owns its data. Sources: Lakehouse deployment pipelines, notebooks in deployment pipelines.

Step 4: Environment-specific configuration (Break 1)

The deployment above worked because everything the notebook used was inside the deployed workspace. Now make the notebook depend on something outside it.

Break it.

  1. In Dev, change nb_load_customers’s default Lakehouse to lh_reference in ws_lifecycle_data_dev, and add a cell:

    spark.sql("SELECT env FROM env_marker").show()
  2. Commit, then deploy the notebook from Development to Test again.

  3. Run the notebook in ws_lifecycle_test.

Expected symptom: the Test notebook prints dev. Nothing fails, which makes this the dangerous kind of deployment problem: Test reads Dev’s data.

Diagnose. Microsoft documents notebook auto-binding for dependencies in the same workspace; lh_reference lives in another workspace, so the Test copy is expected to keep the Dev reference stored in its metadata. Check which Lakehouse, and which workspace, the Test notebook is attached to.

Fix it with a deployment rule.

  1. In the pipeline, select the Test stage, then Deployment rules, then nb_load_customers.
  2. Add a Default lakehouse rule: from lh_reference (Dev) to Other, and enter the Test lh_reference Lakehouse ID, name and workspace ID. The IDs are in the item’s URL.
  3. Deploy the notebook to Test again. Rules only take effect on the next deployment.
  4. Run the notebook in Test. Expected result: test. Microsoft documents that a deployment rule takes priority over auto-binding.

Deployment rules have conditions worth remembering (deployment rule limitations): you must own the item to create one, rules are created on target stages (never on the first stage), and a rule is lost if the item is deleted or the workspace is unassigned from the pipeline. For values that differ by environment across many items, look at variable libraries, which are supported in both Git integration and deployment pipelines; for code-first deployment with parameter files, see Microsoft Fabric CI/CD with fabric-cicd.

Step 5: Change the Warehouse as a database project

Now change the Warehouse schema in code, validate it with a build, and let Git and the pipeline carry it.

  1. Clone the repository and open the wh_sales.Warehouse folder in Visual Studio Code. The Database Projects view should list the project.

  2. Open the .sqlproj file and check the SDK version. Only SDK-style projects are supported for Fabric Warehouse, and an outdated Microsoft.Build.Sql version can fail on newer Warehouse syntax. Microsoft’s guide shows the expected structure; take current version numbers from NuGet rather than from an old example:

    <Sdk Name="Microsoft.Build.Sql" Version="2.3.0" />
  3. Add a view as a new file next to the existing object files, for example v_customers_by_state.sql in the schema’s views folder:

    Consulta SQL: Step 5: Change the Warehouse as a database projectT-SQL (Fabric Warehouse)
    CREATE VIEW dbo.v_customers_by_state AS
    SELECT [state], segment, COUNT(*) AS customers
    FROM dbo.customers
    GROUP BY [state], segment;
    T-SQL (Fabric Warehouse)4 líneasVista de solo lectura. No está conectada a ninguna base de datos.
  4. Build the project (right-click → Build, or from a terminal):

    dotnet build

    Expected result: a successful build and a .dacpac under bin/Debug, as Microsoft’s guide describes. (If the extension’s build fails immediately on Windows, Microsoft currently requires PowerShell as the VS Code default terminal.) An invalid object definition should fail here, before any workspace sees it. That is the main value of building: the build is the test that a CI pipeline runs on every pull request.

  5. Commit and push. In ws_lifecycle_dev, Source control shows an incoming change to wh_sales: select Update all. Microsoft documents that Fabric applies the difference to the Warehouse with an incremental, DacFx-based schema deployment. Query the view in Dev.

  6. In the deployment pipeline, select Compare between Development and Test. The comparison should list the new view for the Warehouse. Deploy it to Test and query it there.

Expected result: one view written as code, validated by a build, applied to Dev from Git and promoted to Test, with the data in both Warehouses untouched. Sources: Warehouse Git integration, deploy Warehouse with pipelines.

Step 6: A blocked deployment (Break 2)

Database deployments are designed to stop when a change could destroy data. Trigger that on purpose, against a disposable copy.

  1. Create a Warehouse wh_sandbox in ws_lifecycle_dev and load dbo.customers into it with the same CREATE TABLE … AS SELECT as in Setup.
  2. In VS Code, publish the project to wh_sandbox once (right-click → Publish, choose the Warehouse connection, Generate Script first, review it, then Publish), so the sandbox matches the project. Save the publish profile when asked.
  3. Now delete the email column from the customers table file, build, and publish to wh_sandbox again with Generate Script.

Expected symptom: the deployment should be blocked because the change would cause data loss: the table has rows, and dropping a column would destroy them. The exact wording depends on the tool and version, so record the message you get. Microsoft documents that deployment pipelines always deploy Warehouses with this protection on (Warehouse deployment configurations).

Diagnose. Review the generated script for the column drop, and the publish output for the data-loss reason. The deployment setting behind the block is BlockOnPossibleDataLoss, which Microsoft recommends keeping on in production (important deployment settings).

Fix. Decide on purpose. Either restore the column in the project (the usual answer), or, in a sandbox only, back up the data first and publish with the protection off:

SqlPackage /Action:Publish \
  /SourceFile:bin/Debug/<project-name>.dacpac \
  /TargetConnectionString:"Server=<id>.datawarehouse.fabric.microsoft.com;Database=wh_sandbox;Authentication=Active Directory Interactive" \
  /p:BlockOnPossibleDataLoss=False

Then restore the column in the project before you commit anything: this change must never reach main.

Two related behaviours to know before you rely on pipelines for Warehouse changes. Deployments through pipelines don’t drop objects that exist only in the target, and a deployment can report success while skipping a requested table drop; compare the stages afterwards to catch the drift. They also exclude users and permissions, so security such as the grants and policies from the Fabric Security Lab has to be applied per environment, for example with a reviewed script.

Troubleshooting

These rows come from Microsoft’s documented behaviour and limitations for Git integration, deployment pipelines and Warehouse source control, not from incidents reproduced for this lab.

Symptom Likely cause Fix
Test notebook reads Dev data Dependency outside the deployed workspace; no rule Default lakehouse rule on the Test stage, then redeploy
A rule exists but nothing changed Rules apply on the next deployment Deploy the item again
Deployment rules is greyed out You aren’t the item’s owner, or you’re on the first stage Take over the item or ask its owner; create the rule on the target stage
A second copy of an item appears in Test The items weren’t paired, so deployment created a new one Pair by assigning the workspace with matching items, or remove the duplicate and redeploy
Test Lakehouse or Warehouse is empty Data is never deployed Load data per environment
Update from Git fails on the Warehouse Outdated .sqlproj SDK, a three-part name referencing the same Warehouse, or a cyclic reference between Warehouses Update the SDK version; use two-part names inside the Warehouse; remove the cycle
Warehouse users or grants missing in Test Security objects are excluded from Warehouse deployments Apply security per environment
Pipeline says success but a table still exists in Test Table drops are blocked by default Compare stages; drop deliberately if intended
Commits blocked by an unexpected DataflowsStagingWarehouse item A Dataflow Gen2 writes to the Warehouse Avoid that pattern in Git-connected Warehouse workspaces for now

Rollback and recovery expectations

What went wrong What rolls it back What doesn’t come back
A bad notebook or pipeline change Revert the commit in Git, update the workspace, redeploy to later stages Run history and outputs of the bad runs
A bad Warehouse schema change Revert the project change, or restore the Warehouse in place from a restore point (system restore points every eight hours, plus user-defined ones) Restore in place overwrites the whole Warehouse, including data written since the restore point
Wrong data loaded into a table Delta time travel and Warehouse restore points, within retention Git: it never had the data
A deleted workspace or item Item and workspace recovery within the tenant’s retention Anything not recreated from Git, such as settings, roles and data

Create a user-defined Warehouse restore point before a risky schema deployment. For the full recovery design, including what Microsoft recovers and what you rebuild, see Recovery and Disaster Recovery Architecture for Microsoft Fabric.

Explain

Answer these without notes:

  1. Why do you need both Git and a deployment pipeline? Git records what changed and who approved it; the pipeline decides which environment gets which state, with rules for what differs per environment.
  2. Where does a database project fit? It is the Warehouse’s schema as code. The build validates it; a schema-aware deploy applies only differences and refuses to lose data unless told to.
  3. What does none of the three protect? Data, secrets, workspace roles and most settings. Those need their own process: load per environment, a secret store, scripted security and the recovery design.

Cleanup

  1. Delete the deployment pipeline dp_lifecycle_lab (this doesn’t delete the workspaces).
  2. Disconnect ws_lifecycle_dev from Git, then delete the four workspaces.
  3. Keep or archive the repository: its history is the evidence of this lab.

What this lab doesn’t cover

Lab 06 in the labs roadmap will apply the same workflow to the Lab 01 sales platform.

Sources

Last verified against Microsoft Learn: November 2026.

Etiquetas

  • Microsoft Fabric
  • CI/CD
  • Git
  • Fabric Warehouse
  • DevOps