r/MicrosoftFabric • • 3d ago

Data Engineering On-Prem data source support inside Notebook

This just popped up on the roadmap:

Does this mean i can query my on-prem DBs via Notebook + Gateway now? Is there any more guidance on how this would be done?

You Microsoft people can't just tease me like that and then not publish a blog post to go along with it ;)

14 Upvotes

13 comments sorted by

6

u/Data_cruncher Moderator 3d ago edited 3d ago

Spark can already directly connect to on-premises sources under strict networking controls. Unfortunately, until Azure PLS Direct Connect becomes GA, it currently requires complex Azure networking.

This feature you’re sharing is elegant in setup assuming a GW+connections are pre-provisioned to your on-premises source. However, consider the implications in that Spark itself is not running its unmanaged code directly against the source; instead, it’s by proxy of the MashUp engine.

2

u/radioblaster Fabricator 3d ago

https://learn.microsoft.com/en-us/fabric/data-engineering/notebookutils/notebookutils-power-query

as of last week, wasn't available in my region. 

I also suspect this will incur DFG2 CU prices, but that's only my untested theory. 

2

u/Cheap_Package_843 3d ago

This works but it only takes an M query, I'm not able to pass a SQL query due to some NativeQuery permission issue.

It works in both PySpark and Python Only. In Python Only it returns a pandas dataframe (not ideal).

A neat solution nonetheless.

1

u/aboerg Fabricator 3d ago

This looks good. 180 second timeout will be a little tricky, but not too bad.

Last I checked, it seemed like running PQ from a notebook required a DFg2 object to exist as a proxy, but this notebookutils approach doesn't seem to need that anymore. If WI works without any issue, I can see myself using this instead of DFg2 for some file-based on-prem sources.

2

u/radioblaster Fabricator 2d ago

i did some fiddling around with this.

conclusion:

  • this is a very interesting method of retrieving small to medium sized data in cases where maintaining a separate pipeline or other item would be overkill, or where the native power query connector provides something you can't re-create externally easily, or has a linked credential.
  • this is a poor method of retrieving anything substantiative and you are far better off sinking your data to binary and reading it in the notebook directly, both from a cost, scale, and reliability perspective
  • it's cool to be able to re-use existing connections with no additional configuration.
  • if you are looking at a 20 second runtime, where the performance appears to be on par with copy data and copy job implementations, paying the extra ~200 CU's for the run if there's a clear benefit could be worth it. if you're doing it "just because", then it's not an effective use of your CU's.

billing: the queries go against the Dataflows Gen2 Run Query API, so you're paying the full 12 CU/s billed as background.

large items: Folder.Files -> select csv with 4,503,915 rows that took 1:30 to materialize via Table.RowCount() in a DFG2, failed after 2 minutes with an error multiple times, all some variation of "Expected to be able to read 177920 bytes for message body, got 159756" with different numbers each time.

small items: Folder.Files -> select csv with 7699 rows came back in 12 seconds. this was not too far off it's performance in a Copy Job.

binary: it will not transfer binary content, tables only.

1

u/TrebleCleft1 3d ago

I’ve been experimenting with Cloudflare (Tunnels + Zero Trust) for this, along with SOPS + age for securing the token that authenticates the connection, although you could always use Azure Key Vault for that.

Pilots are working pretty well so far, although I imagine if you’re in a more locked down networking context there would be some hurdles to get over

1

u/kieranimal 3d ago

I am trying to figure out how to even configure this. When I try to add a connection in the notebook, it doesnt include any on prem option

1

u/PublicAcceptable2472 3d ago

Have you looked into this web page?
https://learn.microsoft.com/en-us/fabric/security/security-managed-private-endpoints-create

Basically with MPE you can connect to on premise resources, e.g. a SQL server database

1

u/kieranimal 3d ago

As far as I can tell - this only is configurable for Azure resources (cloud).
What am I supposed to put in the resource identifier for an on prem server?

1

u/MonkeyDDataHQ 3d ago

You don't. That's the PE that connects to the gateway that connects to on prem server.

Yes, I'm serious.

1

u/kieranimal 2d ago

So I need to configure a gateway in Azure to my on prem, then connect the PVE to that gateway? WTF

2

u/MonkeyDDataHQ 2d ago

My bad, that's all you need in Databricks. In Fabric it's worse. 😩

Correction to my earlier explanation: a Fabric Managed Private Endpoint (MPE) doesn't connect directly to an on-premises data gateway.

For a Spark notebook connecting privately to an on-prem SQL Server, Microsoft's documented architecture is:

Fabric Spark Notebook → Managed Private Endpoint → Azure Private Link Service → Azure Load Balancer → VPN/ExpressRoute → On-prem SQL Server.

You'll also need to configure routing, DNS, and approve the private endpoint connection.

The MPE targeting a Private Link Service must be created through the Fabric REST API, not the UI.

There's also a newer Private Link Service Direct Connect option in preview that can eliminate the load balancer for supported configurations.

Alternatively, an on-premises data gateway can serve supported Data Factory pipeline activities, but that's a different connection mechanism from direct Spark notebook access.

Yes, this is the documented approach.

No, I don't understand why connecting a notebook to an existing SQL Server needs to be this complicated either. 😂

Microsoft documentation: https://learn.microsoft.com/en-us/fabric/security/connect-to-on-premise-sources-using-managed-private-endpoints

1

u/Lomholdt90 3d ago

I gave gemini the link to learn, it created a notebook which use a on-prem gateway, and connects with a Web query to a internal hosted server. Worked first try