In my previous piece I described how I build Power BI reports as code, without Power BI Desktop. Those reports read straight from the production database, through views that return exactly what a report shows. That worked, but it chafed in three places. This week I put a data warehouse next to it for the same client, in Microsoft Fabric, on the same capacity. Below is how and why, and what Fabric doesn’t tell you along the way.
Why not just stay on production
- Load. Every DirectQuery report is a query on the database clients trade on. A heavy page on a Monday morning is something you feel in the application.
- No history. The source only knows the current state. “How much was at that location on 1 October?” can’t be answered if nobody recorded it at the time.
- A connector for colleagues. I wanted colleagues to be able to ask questions about company data in Claude. You don’t do that on a production database full of client details.
That last point was the real trigger, and it also set the main design rule: no personal data, in any layer. Not in the end product, and not in the raw copy either.
Warehouse or lakehouse
Fabric offers two flavours. A lakehouse is Spark and notebooks; a warehouse is T-SQL with tables, views and stored procedures. The team knows SQL, the source is SQL, the reports read SQL views. A warehouse was the easy choice.
What sets the warehouse apart from a classic SQL Server: all tables live in OneLake as Delta Parquet. That’s an open format. Power BI can read it with Direct Lake without a copy, and a Spark notebook can read the same tables later without an export. You build in T-SQL, but you’re not locked into T-SQL. (Fabric Data Warehouse)
And it cost nothing extra. The warehouse runs in its own workspace on the F2 that was already there for the reports.
The layout
Production database (Azure SQL)
│ nightly copy: only the columns needed,
│ large tables incremental, never PII
▼
stg.* narrow copy per source table
│ T-SQL procedures (etl.*)
▼
shared.* account.* portfolio.* ... one schema per domain
│ dimensions, facts, snapshots
▼
rpt.* one view per report ──▶ Power BI
domain schemas (read only) ──▶ Claude connector
A few choices that make the difference:
- One schema per domain, with
dim_andfact_tables. If you’re looking for something about accounts, you look inaccount, not in a flat schema with two hundred tables. - Natural keys. The source has stable integer ids. They stay the key. No surrogate keys to translate on every join.
- Daily snapshots only where the source has no history: positions, balances, open orders. A run for a date replaces that date, so you can safely run it again.
- History (SCD2) only where the question “what was it like on date X” actually gets asked.
- Fixed values live in a parameter table with a valid-from date, not in code. An annual revision is a row, not a release.
Privacy lives in the source, not in the report
The usual approach is to copy everything and hide it in the reporting layer. Then the names and addresses are still in your warehouse, in every backup, and visible to anyone with read access to stg. I turned it around.
- The warehouse has its own identity. The pipeline runs under Fabric’s workspace identity, not under my account. No password, no secret that expires, and it doesn’t stop when I leave.
- That identity may only read specific columns on production. A script generates the per-column
GRANT SELECTfrom the same copy list the pipeline uses. A column that isn’t on the list can’t even be requested by the pipeline. The database enforces the privacy rule, not my discipline. - Where a value sits next to PII, production masks it first. A few fields are needed but live in a record with personal data, such as a contract stored as JSON. Production gets a view for that which extracts or masks the fields needed. Only that view crosses the line. Client names arrive partly masked (the first four characters and
****), so a colleague recognises an account without the name being in the warehouse. - Free text stays out. Remarks and notes can contain anything. While moving a report over, one view turned out to have a column with analysis notes. That column was dropped rather than copied.
In the warehouse, a client is a number. That’s enough to count, group and follow over time. Anyone who wants to know who it is looks in the application, with the permissions that apply there.
The pipeline is code
The nightly copy is one Fabric pipeline using a standard pattern Microsoft calls metadata-driven ingestion: a Lookup reads the copy list, a ForEach loops over it, and per table an If condition picks a full or an incremental copy. (Incremental copy)
- The copy list is a YAML file in Git: which table, which columns, full or incremental, and on which watermark column.
- Incremental uses a watermark plus an hour of overlap, and writes with Upsert on the key. The overlap catches transactions that started before the old watermark but committed later. A full reload follows weekly, because a watermark doesn’t see deleted rows.
- The pipeline itself is generated by a Python script that writes the JSON definition and deploys it through the Fabric REST API, schedule included. Change something in the portal and it disappears on the next deploy. That’s deliberate.
- Every run logs start, end, and rows read and written per step to a log table. After the copy, one procedure loads the domains in a fixed order. Then checks per domain compare counts and totals with production.
The run starts every night at 00:15. That’s the quietest hour on production, before the other night jobs. The first full copy took 53 minutes; the domains then load in five.
What Fabric Warehouse doesn’t tell you
Fabric Warehouse speaks T-SQL, but it isn’t SQL Server. These are the things I ran into, all documented on Microsoft Learn:
- Choose the collation before you create the warehouse. The default is case-sensitive and binary. With it,
WHERE status = 'active'doesn’t find'Active', and joins on text codes silently drop rows. You can’t change it afterwards. (Collation) - Keys aren’t enforced. A primary key must be
NONCLUSTEREDandNOT ENFORCEDand can only be added withALTER TABLE. Preventing duplicate keys is your load procedure’s job. (Table constraints) - No
DEFAULT, noCHECK, no computed columns, no triggers. You fill a load timestamp explicitly in everyINSERT. (Tables) - Locking is per table, not per row. Two updates on the same table collide, even when they touch different rows. So load procedures run one after the other and log tables are append-only. (Transactions)
uniqueidentifierisn’t readable through Direct Lake. It works in the warehouse, but Delta stores it as binary. Store GUIDs a report needs to see aschar(36). (Data types)nvarchar,datetimeandmoneyaren’t allowed as column types. In variables and expressions they are.varcharwith the UTF-8 collation stores Unicode fine, but counts bytes rather than characters: size generously.- The Copy activity handles decimals up to precision 28. Cast a
decimal(38,x)from the source in the source query. (Azure SQL Database connector) - The Fabric connector for Azure SQL can’t (yet) target the readable replica. In Azure Data Factory you set
ApplicationIntent=ReadOnly; in Fabric that option is missing. That’s why the copy runs at night, reads only the columns it needs, and copies at most four tables at a time. (Connector parity)
I had that list researched and checked against Microsoft Learn before a single table existed. That saved throwing away a warehouse over the collation.
Reports move over one by one
A big bang would break every report at once. So each report gets a view in the rpt schema of the warehouse, with the same name and columns as the production view it replaces. Then:
- Compare the two views row by row. The first report returned 2,348 rows, identical on both sides.
- Switch the model to import from the warehouse, through one shared connection with a service principal that may only read
rpt. - Put a badge in the report header that says when the warehouse was loaded, not when the model was refreshed. A user should see that it’s last night’s state.
Because the generator from my previous piece writes the model, the switch is one line: SOURCE = 'dwh'. The report itself doesn’t change. The first two reports moved over today. Reports that genuinely show client details stay on production; they don’t belong in a warehouse without names.
The connector: asking questions without SQL
The finishing piece is a small MCP server: a Claude connector colleagues can add in Claude Team. Questions like “what’s the oldest position”, “who trades most on the platform” or “how much is at location X” get answered by Claude writing its own query against the warehouse.
- Two tools.
gegevens_overzichtreturns tables, columns, conventions and example questions.vraagruns one SELECT, with at most 200 rows. - Sign-in with Entra ID. Only members of one Entra group get in. Every question is written to the audit log with the user.
- Two locks on the door. The database lets the server’s identity read only the domain schemas, never
stgoretl. On top of that, the server itself only lets through a single SELECT on allowed objects. If one lock fails, the other holds. - Cost: an Azure Container App at ten to fifteen euros a month.
Because there’s no personal data in the warehouse, none can leak through the connector either. That’s the reason to solve privacy at the source: everything that comes after doesn’t have to solve it again.
What I’d do differently, and what not
- Start with the privacy classification, not the tables. The design’s appendix classifies every column of every copied source table. It felt like paperwork, but it produced the copy list, the column permissions on production and the checks.
- Let the database enforce the rules. Column permissions, a
DENYon schemas, one identity per application. A rule in a README is a good intention; aGRANTis a fact. - Pipeline as code isn’t a luxury. A pipeline you click together in the portal can’t be reviewed or repeated.
- Compare, compare, compare. Every report moved over matches the original row by row, or the difference is explained.
The warehouse, the pipeline and the connector were up in two days, with Claude Code as my build partner and Microsoft Learn as referee. The long line of reports still to come is now routine: a view, a comparison, one line in the generator.