Hey there,
i am having the same problem - more informations would be awesome!
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi Team,
I am trying to connect to a Microsoft Fabric Lakehouse (via SQL endpoint) using a Node.js application, similar to how it's done in Python using pyodbc and an Azure AD service principal.
In Python, I’m able to connect like this:
import logging
import urllib.parse from sqlalchemy
import create_engine, text
import pandas as pd
odbc_str = ( f"Driver={DRIVER};" f"Server=tcp:{SERVER},1433;" f"Database={DATABASE};" f"UID={CLIENT_ID}@{TENANT_ID};" f"PWD={CLIENT_SECRET};" "Authentication=ActiveDirectoryServicePrincipal;" ) conn_url = "mssql+pyodbc:///?odbc_connect=" + urllib.parse.quote_plus(odbc_str) print(f"Connecting with URL: {conn_url}")
I want to do the same in Node.js, but the odbc package in Node doesn't accept Authentication=ActiveDirectoryServicePrincipal in the connection string.
My Questions:
What is the recommended method to connect to Microsoft Fabric Lakehouse using Node.js + ODBC + AAD Service Principal?
Can Microsoft provide an updated example for Node.js or JavaScript similar to the working Python version?
access_token) from Node.js?Hey there,
i am having the same problem - more informations would be awesome!
Hi there - I struggled with this using the mssql and tedious packages, tried using the optional msnodesqlv8 package with mssql, pored through debug logs and the mssql/tedious packages themselves, and am thoroughly convinced that any current solution cannot rely on those packages. However, here is a solution using the msnodesqlv8 package and the latest ODBC driver 18 for SQL Server without tedious or mssql.
const sql = require('msnodesqlv8');
// Connection string for Azure SQL (Lakehouse)
const connectionString = `
Driver={ODBC Driver 18 for SQL Server};
Server=<your-endpoint.datawarehouse.fabric.microsoft.com>;
Database=<your-database-name>;
Authentication=ActiveDirectoryServicePrincipal;
UID=<your-app-registration-id>@<your-tenant-id>;
PWD=<your-app-registration-secret>;
`;
const query = 'SELECT TOP 10 * FROM sys.tables';
sql.open(connectionString, (err, conn) => {
if (err) {
console.error('Connection error:', err);
return;
}
conn.query(query, (err, rows) => {
if (err) {
console.error('Query error:', err);
} else {
console.log('Query results:', rows);
}
conn.close();
});
});