Connect to an on premise SQL named instance from Azure with nodejs & tedious

One use case we've meet was to connect to an SQL named instance hosted in our on premise datacenter from an nodejs job running on an Azure webjobs.

We have a VNET network associated to our Azure App Service connected to our on-premise datacenter.

(an error message is displayed due to my lack of permission)

In our situation, production (PRO) is hosted with a dynamic port 51210 (yes ... no good practice ...)

Before going any further, checking network connectivity can only be a good idea
tcpping ip_address:port there was one VPN connection, 2 datacenters, several firewalls, an MPLS mesh so we are already happy that connectivity works.

Now I have to configure tedious with correct settings in order to hit this SERVER\PRO instance. I'm using an sql account for connection. I didn't succeed to use an NTLM one (I suspect it's expected)

var Connection = require('tedious').Connection;  
...
var config = {  
    userName: SERVICEACCOUNT_LOGIN,
    password: SERVICEACCOUNT_PASSWORD,
    domain: SERVICEACCOUNT_DOMAIN,
    server: SQLSERVER_IP,
    options : {
        connectTimeout : 5000,
        requestTimeout : 5000,
        encrypt: false,
        port : 51210 // port of the named instance
    }
};

finally enjoy

Fabien Camous

Read more posts by this author.