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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
sambathraj
Regular Visitor

Connect to Azure SQL using Microsoft EntraID from Fabric Notebook

I am trying to connect to the Azure SQL data base from Fabric notebook using my credentials. I was hoping my logged in credentials will be used to get the data from the server. I am able to connect using SSMS. 

 

PYODBC_DRIVER = "{ODBC Driver 18 for SQL Server}"
pyOdbcConnString = "DRIVER={0};SERVER={1};DATABASE={2};Encrypt=yes;Authentication=ActiveDirectoryInteractive;UID=xx@xx.com".format(
                    PYODBC_DRIVER,
                    ServerName,
                    DatabaseName,
                )

I am getting following error. 
OperationalError: ('HYT00', '[HYT00] [Microsoft][ODBC Driver 18 for SQL Server]Login timeout expired (0) (SQLDriverConnect)')

2 REPLIES 2
Anonymous
Not applicable

Hi @sambathraj 

 

I haven't tested Microsoft Entra ID authentication yet. I tested with SQL authentication with below code in a notebook successfully. You may try changing the connection string accordingly. 

import pyodbc

servername = 'your server name'
databasename = 'your db name'
username = 'sql user name'
password = 'xxxxxx'

connection_string = f"Driver={{ODBC Driver 18 for SQL Server}};Server=tcp:{servername}.database.windows.net,1433;Database={databasename};Uid={username};Pwd={password};Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;"

query_string = 'select top 10 * from SalesLT.ProductCategory'

conn = pyodbc.connect(connection_string)
cursor = conn.cursor()
cursor.execute(query_string)
resultList = cursor.fetchall()
for row in resultList:
    print(row)

vjingzhanmsft_0-1724830036787.png

 

You can try adding connection timeout to the connection string. Also ensure that your client IP address has been added in Firewall rules of the Azure SQL database or server.  

connection_str = "Driver={ODBC Driver 18 for SQL Server};Server={server};Database={Database};UID={username};Authentication=ActiveDirectoryInteractive;Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;"

 

Hope this would be helpful. Let me know if you have any questions. 

 

Best Regards,
Jing
If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!

SQL Authentication works fine. I was trying to use Managed Identity / logged in user Entra ID. 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

June FBC25 Carousel

Fabric Monthly Update - June 2025

Check out the June 2025 Fabric update to learn about new features.