Azure web app tedious

允我心安 提交于 2021-02-08 09:50:18

问题


I want to use use tedious in my Azure web app to follow this tutorial https://docs.microsoft.com/en-us/azure/sql-database/sql-database-connect-query-nodejs I get the error "Uncaught Error: Module name "tedious" has not been loaded yet" with require('tedious').Connection. How do I load this module in Azure?

The javascript code:

var Connection = require('tedious').Connection;
var Request = require('tedious').Request;



// Create connection to database
var config = {
  userName: '******', // update me
  password: '*****', // update me
  server: '*******', // update me
  options: {
      database: 'signals' //update me
  }
}
var connection = new Connection(config);

// Attempt to connect and execute queries if connection goes through
connection.on('connect', function(err) {
    if (err) {
        console.log(err)
    }
    else{
        queryDatabase()
    }
});

function queryDatabase(){
    console.log("test");
    console.log("test");
    console.log('Reading rows from the Table...');

    // Read all rows from table
    request = new Request(
        "SELECT * FROM signals",
        function(err, rowCount, rows) {
            console.log(rowCount + ' row(s) returned');
        }
    );

    request.on('row', function(columns) {
        columns.forEach(function(column) {
            console.log("%s\t%s", column.metadata.colName, column.value);
        });
    });

    connection.execSql(request);
} 

回答1:


How do I load this module in Azure?

In Azure, you can install Node.js module through Kudu Debug Console which could be accessed via https://<your-web-app-name>.scm.azurewebsites.net/DebugConsole

  1. cd to D:\home\site\wwwroot in the console.

  2. run the following command inside the wwwroot directory: npm install tedious



来源:https://stackoverflow.com/questions/44134302/azure-web-app-tedious

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!