Your production SQL Server sits inside an office network behind a firewall, and you need a fresh slice of orders or a lookup table in a Microsoft Fabric cloud notebook. Regular pyodbc and JDBC can't reach it because they need direct access to port 1433, which security won't open. Building a full pipeline for two tables feels like overkill.
In the November 2026 Fabric update, Microsoft added notebookutils.powerquery (currently in Preview). It pulls data from a local SQL Server into a notebook with just a few lines of Python.
How a cloud query reaches your local server
The bridge is the On-premises Data Gateway, a Windows service running inside your local network. It only opens outbound connections to Azure, so inbound firewall ports stay closed.
Each query follows five steps:
- The notebook sends a Power Query M script and query name.
- The cloud Power Query engine evaluates the script without using Spark.
- The Fabric connection injects credentials and routes the job to the gateway.
- The gateway runs the query on your local SQL Server (for example,
sql01.corp.contoso.local). - The result comes back as a PySpark DataFrame ready to analyze or save to a Lakehouse (Fabric's unified storage for files and tables).
To start, you need a gateway in standard mode, a connection in Manage connections and gateways, and access rights to it. No passwords live in your notebook code.
Running executeQuery and saving to a Delta Table
Put your Table.SelectRows filter right in the M script. Power Query folds it into a server-side SQL WHERE clause (query folding), so only the matching slice travels over the network:
# Power Query M script with server-side filtering on SQL Server
script = """
let
Src = Sql.Database("sql01.corp.contoso.local", "SalesDB"),
Ord = Src{[Schema = "dbo", Item = "Orders"]}[Data],
Cut = Table.SelectRows(
Ord, each [OrderDate] >= #date(2026, 11, 1)
)
in
Cut
"""
# Run the query through a Fabric connection
df = notebookutils.powerquery.executeQuery(
"RecentOrders",
script,
connections=["onprem-sql01-salesdb"],
)
# Drop the helper NULL column if it appears in the result
if "PQ Arrow Metadata" in df.columns:
df = df.drop("PQ Arrow Metadata")
# Save the result as a Delta Table in Lakehouse
df.write.mode("append").format("delta").saveAsTable("bronze_orders")
The server and database in Sql.Database must match your Fabric connection. From there, df writes into a Delta Table (a Parquet-backed table with a transaction log for safe appends and versioning).
Watch out for two preview quirks. Results include an empty PQ Arrow Metadata column (just drop it), and tinyint columns crash PySpark with UNSUPPORTED_ARROWTYPE unless you cast them to Int32.Type using Table.TransformColumnTypes in the M script.
To read multiple tables at once, start the script with section Section1;, mark tables as shared, and pass a list of names to executeQuery. You get back a QueryResults object with successes and failures dicts, so one failed table won't crash the rest.
Contoso benchmarks, limits, and choosing the right tool
On the Contoso dataset, a one-month slice of FactOnlineSales (478,320 rows) loaded into PySpark in 58 seconds, or about 8,000 rows per second (69.8s in a pandas Python notebook). Counting all 12,627,608 rows took 6 seconds because SQL Server computed the count locally. Meanwhile, a 4-row DimChannel table took 3.7 seconds, showing that per-call overhead makes small loops inefficient.
Preview limits are strict: read-only access, a 180-second gateway timeout (230 seconds in cloud), and a 512 KiB M-script cap. Timeouts can also lag; a full 12.6M-row pull failed with HTTP 408 only after 8 minutes. Also, shared gateways often serve Power BI too, so heavy notebooks will compete for resources.
| Tool | Network | Mode | When to use |
|---|---|---|---|
notebookutils.powerquery | Gateway + connection | Read-only, gateway timeout | Lookups, small slices |
| Pipelines / Copy job | Existing gateway | Bulk loads, CDC | Scheduled extracts |
| Mirroring for SQL Server | Gateway or Azure Arc | Continuous replication | Fresh copies with no code |
Managed Private Endpoints + JDBC/pyodbc | VNet, VPN/ExpressRoute, Private Link | Parallel read and write | Writing back and huge loads |
For lookup tables and quick one-off slices, notebookutils.powerquery saves setup time. For millions of rows and nightly loads, pick Copy job or Mirroring right away. Managed Private Endpoints also disables fast starter pools, stretching Spark session startup to 3–5 minutes.



