I have a SQL Azure database that I'm trying to connect to from a NodeJS application running in an Azure Linux VM. Everything works fine when I'm on a local SQL Database/and local machine for NodeJS. However, when I run from my vm, I get the following output (My trace output plus the Tedious debug event):
connected to XXXXXXX.database.windows.net:1433 State change: Connecting -> SentPrelogin State change: SentPrelogin -> SentLogin7WithStandardLogin connection to XXXXXXX.database.windows.net:1433 closed State change: SentLogin7WithStandardLogin -> Final Writing CSV files.... connection to XXXXXXX.database.windows.net:1433 closed State change: Final -> Final All Done!
The problem is that no error is ever raised, but the connection seems to be automatically closed.
Any thoughts on what might be happening here or how I can get to an actual error?
Ok - solved it thanks to this thread
There were 2 issues:
- SQL Azure requires encrypted connections, so you need encrypt:true in the connection options
- the userName configuration option requires the database-qualified name (e.g. user@XXXXXX.database.windows.net)
Just in case anyone else runs into this :)
This recipe can be found in it's original form on Stack Over Flow.