question

NayakTirthankar-3822 avatar image
0 Votes"
NayakTirthankar-3822 asked RupeshAgarwal-2700 answered

Unable To Connect to Azure SQL on Redhat VM but working on Windows Machine

Code in Python


import pyodbc
server = '<SERVER_NAME>.database.windows.net'
database = '<DB_NAME>'
username = '<USER>@<DOMAIN>.com'
password = '<PASSWORD>'
authentication = 'ActiveDirectoryPassword'
driver= '{ODBC Driver 17 for SQL Server}'

cnxn = pyodbc.connect('DRIVER='+driver+';SERVER='+server+';DATABASE='+database+';UID='+username+';Authentication='+authentication+';PWD='+password)
cursor = cnxn.cursor()
cursor.execute("SELECT @@version;")
row = cursor.fetchone()
while row:
print(row[0])
row = cursor.fetchone()

Error Info on RedHat VM (version 7.2)


Traceback (most recent call last):
File "sample.py", line 9, in <module>
cnxn = pyodbc.connect('DRIVER='+driver+';SERVER='+server+';DATABASE='+database+';UID='+username+';Authentication='+authentication+';PWD='+password)
pyodbc.OperationalError: ('HYT00', '[HYT00] [Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired (0) (SQLDriverConnect)')

The Same piece of Code runs on Windows Machine.
Both have Odbc 17 installed and using 'pyodbc' python library to connect to Database.

Can you please look into this matter ASAP?

Thank You

azure-sql-database
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AnuragSharma-MSFT avatar image
0 Votes"
AnuragSharma-MSFT answered RyanAndrewVolpi-4219 published

Hi @NayakTirthankar-3822, welcome to Microsoft Q&A forum.

Could you please check if you are able to connect from SQL Authentication instead of Active Directory Password once?

Also, please check if public ip of machine has been added to firewall rule.

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello @AnuragSharma-MSFT
I am able to connect using SQL authentication with a native SQL user. I am unable to connect using the Active Directory user(i.e user@domain.com) using SQL authentication. IP of the machine is added to the firewall rule.

0 Votes 0 ·

Did you resolve the issue? I am in the same position I believe.

0 Votes 0 ·
RupeshAgarwal-2700 avatar image
0 Votes"
RupeshAgarwal-2700 answered

any leads on this ?

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.