0

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.

Community
  • 1
  • 1

1 Answers1

0

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.

Peter Pan
  • 23,476
  • 4
  • 25
  • 43
  • Thank you for the information. I want to try it and report the result later. After posting the question, shortly I tried "msnodesqlv8" module. It didn't reproduce the same problem, but "Internal Server Error". If this can be solved, I think the newer v4.2.3 would be better. Is there this way? – Hideki Nishimura Jan 19 '16 at 03:53
  • @HidekiNishimura The module `msnodesqlv8` seems to be a third-party driver. Could you please create a new thread to discuss this issue since your new question is not directly related to the original issue, it would be better if you open up a new thread for the new question. In this way, our discussion here will not deviate too much from the original issue. This will make answer searching in the forum easier and be beneficial to other community members as well. Thanks for your understanding. – Peter Pan Jan 19 '16 at 04:32