<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Connect to On-prem SQL Server via Fabric Notebook in Data Engineering</title>
    <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Connect-to-On-prem-SQL-Server-via-Fabric-Notebook/m-p/3985133#M2502</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/510380"&gt;@wzbeaver&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Thanks for using Fabric Community.&lt;/P&gt;
&lt;P&gt;Here are a few potential solutions and things to check:&lt;/P&gt;
&lt;P&gt;1) &lt;STRONG&gt;Network Settings:&lt;/STRONG&gt; &lt;BR /&gt;Ensure that the network settings allow Fabric to access the VM environment. You might need to set up and use private links for secure access to Fabric.&lt;BR /&gt;&lt;A href="https://learn.microsoft.com/en-us/fabric/security/security-private-links-use#step-4-create-a-virtual-machine" target="_blank"&gt;Set up and use private links for secure access to Fabric - Microsoft Fabric | Microsoft Learn&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://learn.microsoft.com/en-us/fabric/security/security-managed-vnets-fabric-overview" target="_blank"&gt;Overview of managed virtual networks in Microsoft Fabric - Microsoft Fabric | Microsoft Learn&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;2)&lt;STRONG&gt; ODBC Driver:&lt;/STRONG&gt; &lt;BR /&gt;Make sure that the ODBC driver is correctly installed and configured. Sometimes, driver issues can cause connection problems.&lt;BR /&gt;&lt;BR /&gt;3) &lt;STRONG&gt;Permissions:&lt;/STRONG&gt; &lt;BR /&gt;Ensure that the necessary permissions are granted to allow Fabric to access the SQL Server instance.&lt;BR /&gt;&lt;BR /&gt;4) &lt;STRONG&gt;Firewall Settings:&lt;/STRONG&gt; &lt;BR /&gt;Check the firewall settings of the SQL Server instance to ensure that they allow connections from Fabric.&lt;BR /&gt;&lt;BR /&gt;Below is a sample python code for connecting to SQL server using pydobc:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;import pyodbc

# Get the secret value from Key Vault
clientId = "&amp;lt;clientId&amp;gt;" 
tenantId = "&amp;lt;tenantId&amp;gt;"
principalSecret = mssparkutils.credentials.getSecret("https://&amp;lt;keyValutName&amp;gt;.vault.azure.net/", "&amp;lt;secretName&amp;gt;")  

# Set up SQL Server connection details
server = "&amp;lt;SQL Endpoint FQDN&amp;gt;"
database = "&amp;lt;database&amp;gt;"
username = f"{principalId}@{tenantId}"

# Create the connection string with the access token
connection_string = f"Driver={{ODBC Driver 18 for SQL Server}};Server={server};Database={database};Authentication=ActiveDirectoryServicePrincipal;UID={username};PWD={principalSecret};ConnectRetryCount=4"

print(connection_string)
# Connect to the Azure SQL Database using pyodbc
conn = pyodbc.connect(connection_string)


# Execute a query
query = "SELECT @@version version"
cursor = conn.cursor()
cursor.execute(query)

# Fetch all rows from the result set
rows = cursor.fetchall()

# Print the rows
for row in rows:
    print(row)

# Close the connection when done
conn.close()&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;BR /&gt;Hope this helps. Please let me know if you have any further questions.&lt;/P&gt;</description>
    <pubDate>Tue, 11 Jun 2024 06:25:56 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-06-11T06:25:56Z</dc:date>
    <item>
      <title>Connect to On-prem SQL Server via Fabric Notebook</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Connect-to-On-prem-SQL-Server-via-Fabric-Notebook/m-p/3983974#M2485</link>
      <description>&lt;P&gt;I am currently trying to connect to our on-premises (VM) instance of SQL Server 2017 by leveraging the Spark Notebooks available in Fabric.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have successfully done this with an Azure SQL DB instance, and am leveraging the same code structure to attempt to connect to our primary data warehouse hosted on an Azure VM.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, when doing so I receive this error message:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="wzbeaver_1-1718032421363.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1114115i55396ED23C144B16/image-size/medium?v=v2&amp;amp;px=400" role="button" title="wzbeaver_1-1718032421363.png" alt="wzbeaver_1-1718032421363.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have taken the code that I'm using, pictured above, and tested locally in Visual Studio Code, and am able to connect with no issues.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have also installed the ODBC driver 18 on the environment that I'm attempting to connect to.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are there some sort of specific network settings that I need to check on to allow Fabric to access this VM environment? Or is it not possible currently to connect to a VM SQL Server instance via Fabric Notebooks?&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jun 2024 15:18:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Connect-to-On-prem-SQL-Server-via-Fabric-Notebook/m-p/3983974#M2485</guid>
      <dc:creator>wzbeaver</dc:creator>
      <dc:date>2024-06-10T15:18:51Z</dc:date>
    </item>
    <item>
      <title>Re: Connect to On-prem SQL Server via Fabric Notebook</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Connect-to-On-prem-SQL-Server-via-Fabric-Notebook/m-p/3985133#M2502</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/510380"&gt;@wzbeaver&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Thanks for using Fabric Community.&lt;/P&gt;
&lt;P&gt;Here are a few potential solutions and things to check:&lt;/P&gt;
&lt;P&gt;1) &lt;STRONG&gt;Network Settings:&lt;/STRONG&gt; &lt;BR /&gt;Ensure that the network settings allow Fabric to access the VM environment. You might need to set up and use private links for secure access to Fabric.&lt;BR /&gt;&lt;A href="https://learn.microsoft.com/en-us/fabric/security/security-private-links-use#step-4-create-a-virtual-machine" target="_blank"&gt;Set up and use private links for secure access to Fabric - Microsoft Fabric | Microsoft Learn&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://learn.microsoft.com/en-us/fabric/security/security-managed-vnets-fabric-overview" target="_blank"&gt;Overview of managed virtual networks in Microsoft Fabric - Microsoft Fabric | Microsoft Learn&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;2)&lt;STRONG&gt; ODBC Driver:&lt;/STRONG&gt; &lt;BR /&gt;Make sure that the ODBC driver is correctly installed and configured. Sometimes, driver issues can cause connection problems.&lt;BR /&gt;&lt;BR /&gt;3) &lt;STRONG&gt;Permissions:&lt;/STRONG&gt; &lt;BR /&gt;Ensure that the necessary permissions are granted to allow Fabric to access the SQL Server instance.&lt;BR /&gt;&lt;BR /&gt;4) &lt;STRONG&gt;Firewall Settings:&lt;/STRONG&gt; &lt;BR /&gt;Check the firewall settings of the SQL Server instance to ensure that they allow connections from Fabric.&lt;BR /&gt;&lt;BR /&gt;Below is a sample python code for connecting to SQL server using pydobc:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;import pyodbc

# Get the secret value from Key Vault
clientId = "&amp;lt;clientId&amp;gt;" 
tenantId = "&amp;lt;tenantId&amp;gt;"
principalSecret = mssparkutils.credentials.getSecret("https://&amp;lt;keyValutName&amp;gt;.vault.azure.net/", "&amp;lt;secretName&amp;gt;")  

# Set up SQL Server connection details
server = "&amp;lt;SQL Endpoint FQDN&amp;gt;"
database = "&amp;lt;database&amp;gt;"
username = f"{principalId}@{tenantId}"

# Create the connection string with the access token
connection_string = f"Driver={{ODBC Driver 18 for SQL Server}};Server={server};Database={database};Authentication=ActiveDirectoryServicePrincipal;UID={username};PWD={principalSecret};ConnectRetryCount=4"

print(connection_string)
# Connect to the Azure SQL Database using pyodbc
conn = pyodbc.connect(connection_string)


# Execute a query
query = "SELECT @@version version"
cursor = conn.cursor()
cursor.execute(query)

# Fetch all rows from the result set
rows = cursor.fetchall()

# Print the rows
for row in rows:
    print(row)

# Close the connection when done
conn.close()&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;BR /&gt;Hope this helps. Please let me know if you have any further questions.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jun 2024 06:25:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Connect-to-On-prem-SQL-Server-via-Fabric-Notebook/m-p/3985133#M2502</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-06-11T06:25:56Z</dc:date>
    </item>
    <item>
      <title>Re: Connect to On-prem SQL Server via Fabric Notebook</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Connect-to-On-prem-SQL-Server-via-Fabric-Notebook/m-p/3989197#M2543</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/510380"&gt;@wzbeaver&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;SPAN&gt;We haven’t heard from you on the last response and was just checking back to see if your query got resolved. Otherwise, will respond back with the more details and we will try to help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2024 16:26:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Connect-to-On-prem-SQL-Server-via-Fabric-Notebook/m-p/3989197#M2543</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-06-12T16:26:37Z</dc:date>
    </item>
    <item>
      <title>Re: Connect to On-prem SQL Server via Fabric Notebook</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Connect-to-On-prem-SQL-Server-via-Fabric-Notebook/m-p/3989460#M2545</link>
      <description>&lt;P&gt;Hey&amp;nbsp;@Anonymous&amp;nbsp;I greatly appreciate you responding and providing the level of detail that you have. I have read through your response, but have not yet gotten an opportunity to vet the recommendations that were provided. I will be trying to do so this week, and will be sure to respond back once I either find a solution or reach another dead end.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2024 19:13:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Connect-to-On-prem-SQL-Server-via-Fabric-Notebook/m-p/3989460#M2545</guid>
      <dc:creator>wzbeaver</dc:creator>
      <dc:date>2024-06-12T19:13:52Z</dc:date>
    </item>
    <item>
      <title>Re: Connect to On-prem SQL Server via Fabric Notebook</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Connect-to-On-prem-SQL-Server-via-Fabric-Notebook/m-p/3996244#M2603</link>
      <description>&lt;P&gt;Hey All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just following up again. I have read through the provided articles and the steps provided make sense as I do suspect that we need to enable the Fabric tenant to communicate on the same VNET. I have not yet set this up since our organization tenant is currently used for production Power BI as well as our development Fabric capacity, and I did not want to enable this Managed Private Endpoint configuration at the tenant level until I discuss the potential implications with our infosec/networking team.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jun 2024 13:46:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Connect-to-On-prem-SQL-Server-via-Fabric-Notebook/m-p/3996244#M2603</guid>
      <dc:creator>wzbeaver</dc:creator>
      <dc:date>2024-06-17T13:46:16Z</dc:date>
    </item>
    <item>
      <title>Re: Connect to On-prem SQL Server via Fabric Notebook</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Connect-to-On-prem-SQL-Server-via-Fabric-Notebook/m-p/4009577#M2682</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/510380" target="_blank"&gt;@wzbeaver&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;We haven’t heard from you on the last response and was just checking back to see if your query got resolved. Otherwise, will respond back with the more details and we will try to help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2024 17:01:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Connect-to-On-prem-SQL-Server-via-Fabric-Notebook/m-p/4009577#M2682</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-06-25T17:01:44Z</dc:date>
    </item>
    <item>
      <title>Re: Connect to On-prem SQL Server via Fabric Notebook</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Connect-to-On-prem-SQL-Server-via-Fabric-Notebook/m-p/4342205#M5761</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;May be below is answer to issue posted here ... !!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.fabric.microsoft.com/t5/Data-Engineering/Notebooks-On-Prem-SQL-server-to-Lakehouse/m-p/4019995/highlight/true#M2787" target="_blank"&gt;https://community.fabric.microsoft.com/t5/Data-Engineering/Notebooks-On-Prem-SQL-server-to-Lakehouse/m-p/4019995/highlight/true#M2787&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FYI - &lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/510380"&gt;@wzbeaver&lt;/a&gt;, @Anonymous&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or if above link is Not an answer then please post another solution because i am facing same issue now.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 24 Dec 2024 14:23:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Connect-to-On-prem-SQL-Server-via-Fabric-Notebook/m-p/4342205#M5761</guid>
      <dc:creator>Devsql1234</dc:creator>
      <dc:date>2024-12-24T14:23:03Z</dc:date>
    </item>
    <item>
      <title>Re: Connect to On-prem SQL Server via Fabric Notebook</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Connect-to-On-prem-SQL-Server-via-Fabric-Notebook/m-p/4416699#M7328</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/510380"&gt;@wzbeaver&lt;/a&gt;&amp;nbsp;, did you find any resolution on connecting notebooks to on-prem SQL server? please share. It will be much helpful. Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2025 01:49:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Connect-to-On-prem-SQL-Server-via-Fabric-Notebook/m-p/4416699#M7328</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-02-19T01:49:50Z</dc:date>
    </item>
    <item>
      <title>Re: Connect to On-prem SQL Server via Fabric Notebook</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Connect-to-On-prem-SQL-Server-via-Fabric-Notebook/m-p/4801605#M11825</link>
      <description>&lt;P&gt;Hey All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I appreciate the follow up here, unfortunately was unable to get back to you all in a timely manner. My team is now finally in a position to work on this activity I will forward these details to them and see if we can mark this as resolved.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Aug 2025 02:48:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Connect-to-On-prem-SQL-Server-via-Fabric-Notebook/m-p/4801605#M11825</guid>
      <dc:creator>wzbeaver</dc:creator>
      <dc:date>2025-08-20T02:48:15Z</dc:date>
    </item>
  </channel>
</rss>

