Skip to main content
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

New Member

Using a VNet gateway with Notebooks

We just set up our VNet on prem server to connect to an AWS PostGreSQL database with the latest release of Fabric.

It works great with the Pipeline, but after some discussions with MS consultants, our use case for data delivery will be best met by using Notebooks and pspark queries.

However, I don't see a method to trigger the query through the gateway to get to the data, so we get errors that we can't connect to the source.

Does anyone know a work around? 

We want to avoid using pipelines in the solution unless the pipeline is trigged somehow in the Notebook. 


Do you know if this feature is available for "On-Premises Data Gateways"?

View solution in original post

New Member

I'm unsure what you are asking beyond the information i provided.

We have enabled the On-prem gateways so that Pipelines and Gen2 dataflows can connect to an AWS PostGreSQL RDS database. That works fine with the Pipeline. But we want to use Notebooks instead to query and pull that data in. The Notebook query template given to us by Microsoft consultants Was:


# Import necessary libraries
from pyspark.sql import SparkSession
# Create a Spark session
spark = SparkSession.builder \
    .appName("Read from PostgreSQL") \
# Define the PostgreSQL connection properties
jdbc_url = "jdbc:postgresql://your-postgres-hostname:5432/your-database"
connection_properties = {
    "user": "your-username",
    "password": "your-password",
    "driver": "org.postgresql.Driver"
# Read data from a table in the PostgreSQL database
table_name = "your_table_name"
df =, table=table_name, properties=connection_properties)
# Show the data
# Stop the Spark session

 However, we should be triggering the gateway and not including the username and password in the code. 


Hi @eb38335 ,

I suggest you to use Azure Key Vault Secrets inorder to store your username and password.
Accessing Azure Key Vault Secrets from Fabric Notebooks (

Additional Docs to refer -
Solved: Microsoft Fabric connect to Azure Key Vault - Microsoft Fabric Community

Hope this is helpful. Please let me know incase of further queries.

Actually, that's what the gateway does. It manages the connection from Fabric to the database for the query when the database path matches what's in the gateway path.

However, I'm unsure how we invoke the gateway from the Notebook like it is invoked from the Pipeline.

Hi @eb38335 ,

Currently we can only invoke the gateway using Pipeline, we cannot invoke it using Fabric Notebooks.

Docs to refer -
VNET Data Gateway for Fabric and Power BI is now Generally Available | Microsoft Fabric Blog | Micro...

What is a virtual network (VNet) data gateway | Microsoft Learn


Hope this is helpful. Please let me know incase of further queries.

Do you know if this feature is available for "On-Premises Data Gateways"?

Hi @eb38335 ,

On-Prem Gateway is supported only for Dataflow Gen 2 and Data Pipeline.

Docs to refer -
How to access on-premises data sources in Data Factory - Microsoft Fabric | Microsoft Learn

Hope this is helpful

Community Support
Community Support

Hi @eb38335 ,

Thanks for using Fabric Community.
I would like to understand what is the present approach you are following? 
What approach you are interested in? Any informaion about your Source and Sink?
Can you please provide these details inorder to guide you better.

Helpful resources

Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.


Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.


Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.