首页 文章

Microsoft Azure node-sqlserver问题

提问于
浏览
0

计划使用node.js在Windows Azure网站上构建新项目,我遇到了SQL Server模块的问题,我无法解决:

我正在使用下载的模块二进制文件,使用示例中的简单代码连接到Azure托管的SQL Server:

var sql = require('node-sqlserver');
var http = require('http');

var conn_str = "Driver={SQL Server Native Client 10.0};Server=tcp:server.database.windows.net,1433;Database=database;Uid=user@server;Pwd=mypass;Encrypt=yes;Connection Timeout=30;";

var port = process.env.port||3000;
http.createServer(function (req, res) {

sql.query(conn_str, "SELECT * FROM testdb.testtable", function (err, results) {
    if (err) {
        res.writeHead(500, { 'Content-Type': 'text/plain' });
        res.write("Got error :-( " + err);
        res.end("");
        return;
    }
    res.writeHead(200, { 'Content-Type': 'text/plain' });
    res.end(JSON.stringify(results));
});

}).listen(port);

该示例在我的PC本地工作,它能够连接到Azure SQL并检索行,虽然我不得不将节点降级到0.6.19以使其工作,但是当我将其部署到Azure时它失败了 . 当我尝试访问网站时,经过漫长的等待时间后,我收到:

iisnode encountered an error when processing the request.

HRESULT: 0x6d
HTTP status: 500
HTTP reason: Internal Server Error
You are receiving this HTTP 200 response because system.webServer/iisnode/@devErrorsEnabled configuration setting is 'true'.

In addition to the log of stdout and stderr of the node.exe process, consider using debugging and ETW     traces to further diagnose the problem.

The node.exe process has not written any information to the stdout or stderr.

我尝试从源代码编译node-sqlserver模块,并再次在我的PC上工作,在Azure上具有相同的结果 . 我还验证了模块二进制文件的部署(我正在使用git进行部署) .

有任何想法吗?

1 回答

  • 1

    好吧,结果是,SQL数据库和网站在不同的地理区域,尽管“提供给Azure服务”设置,但Azure无法连接到不同区域的SQL服务器 . 不得不移动数据库,它的工作原理 .

相关问题