'Azure SQL Database, NodeJS app: failed to connect

probably someone has encounterd the same problem and have a solution.

I have a SQL Database in my Azure Portal account. I have created a NodeJS application in a website, using CPanel > Setup NodeJS App funtionality.

Then I installed the mssql plugin for connecting a NodeJS app with an Azure SQL Database. This is my starting, connection code:

let sqlConfigTEST = {
    user: "my_user_name",
    password: "my_password",
    database: "my_db_name",
    server: "my_url_to.database.windows.net",
    port: 1433,
    pool: {
        max: 70,
        min: 0,
        idleTimeoutMillis: 30000
    },
    options: {
        encrypt: true,
        trustServerCertificate: false
    }
};

var myDB = new SQL.ConnectionPool(sqlConfigTEST, err => { if (err) { console.log(err); } else { console.log("OK"); } });

When I launch the app, the ConnectionPool() method rises this error:

ConnectionError: Failed to connect to my_url_tp.database.windows.net:1433 - Could not connect (sequence) App 1801 output: at /home/qgsqpvwr/nodevenv/dashboard/12/lib/node_modules/mssql/lib/tedious/connection-pool.js:70:17 . . . etc, etc . . . App 1801 output: code: 'ESOCKET', App 1801 output: isTransient: undefined

Basically, it's just the for some reason my app can't remotelly communicate with my Azure DB. The only thing I tryed is to add my website shared IP to the Azure Firewall rules, but it didn't worked.

Anyone can help me with this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source