0

I'm baffled. I'm trying to connect to an Azure SQL database (managed, not a VM) from an Azure VM running Ubuntu. I'm using python FreeTDS ODBC with a connection string that looks like:

Driver=FreeTDS;Server=mycompany.database.windows.net;Database=mydbname;UID=myusername;PWD=secret;Port=1433;Timeout=30

When I try to connect from the ubuntu VM I get a timeout:

[FreeTDS][SQL Server]Timeout expired (0) (SQLDriverConnect)

It doesn't matter what kind of timeout parameters I supply, either in the connection string or in the pyodbc connect() arguments. The timeout happens in about a second, not thirty.

I can telnet to the server on 1433 and something answers, from both my local machine and the VM. I can ping it from the VM but not from my local machine. The hostname resolves to the same IP on the VM and my local machine.

Here's the crazy thing - it works on my local machine. In fact, if I use ssh tunneling to route the Azure VM THROUGH my local machine, it WORKS, with the same exact connection string.

At this point, I've tried adding a temporary allow 0/32 on the Azure VM's firewall just to rule it out. There's no difference.

I'm sure there's some checkbox or something I'm missing on the Azure side, but I can't figure it out! I've checked the "Allow Azure services to access this resource" or whatever on the SQL instance.

Hoping someone can point out what I'm missing!

2
  • Did you telnet/ping from your VM? Just clarifying. Commented Jun 5 at 16:16
  • @mxmissile Yeah, and ping works and telnet at least connects to something. Turns out it's something about FreeTDS. Commented Jun 5 at 16:41

1 Answer 1

1

Out of desperation I tried switching to the Microsoft ODBC drivers instead of FreeTDS. And somehow, that works.

I have no idea why, as it's clearly something about the Azure environment, since FreeTDS absolutely works when using an ssh tunnel to forward the connection through some external host. But the Microsoft ODBC driver apparently knows the secret sauce Azure wants.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.