简体   繁体   中英

Deploying a node app using msnodesql fails on azure Web apps site

I tried to run a node.js code on Azure Web apps using msnodesql to Azure SQL Database, but it fails.

I checked the comment ( node.js + azure sql database ), but it didn't work yet.

Now I checked node version on Azure by the tool "console" on the site, it showed v4.2.3. I understand msnodesql ( https://www.npmjs.com/package/msnodesql ) now supports node v0.8 or v0.6.

I suspect that version mismatch of them may be the reason of the failure. I installed node v4.2.3 on my PC locally, then I could reproduce this problem with v0.6 and v0.8 msnodesql (sqlserver.node).

Does anyone have a workaround? I couldn't find a way to downgrade the Azure node.js.


(2016/1/20)

Thanks to @PeterPan, I can run the program on Azure with the module "tedious" finally. Thank you very much.

I didn't try, but I could specify Node.js version to use the module msnodesql, according to https://azure.microsoft.com/en-us/documentation/articles/nodejs-specify-node-version-azure-apps/#using-a-custom-version-with-azure-websites .

However, I still wonder which way is better, Node v4.2.3 with tedious, Node v4.2.3 with msnodesqlv8 (I coudn't make sure yet that it does work), or Node v0.8 with msnodesql/msnodesqlv8 .

I would like to discuss this in a different thread.

You can try to specify the NodeJS version (that in the json list at https://your_web_app_name.scm.azurewebsites.net/api/diagnostics/runtime ) in the package.json file of your project, such as below.

"engines":{"node": "0.6.22 || 0.8.x"}

Or you can try to refer to the section Using a custom version with Azure Websites of Azure offical document Specifying a Node.js version in an Azure application to use a custom version.

If you don't have to use the package node-sqlserver , you also can try to use the pure JavaScript driver Tedious with no dependencies. And you can refer to the doc https://azure.microsoft.com/en-us/documentation/articles/sql-database-develop-nodejs-simple-windows/ to know how to use it.

Note : On Azure, some modules of NodeJS compiled at install time, usually by using Python and node-gyp, like node-sqlserver that is a native C driver that uses the Microsoft ODBC driver under the hood. If you got this kind of issue, you can refer to the section Native Modules of the doc Using Node.js Modules with Azure applications .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM