Running Azure Node.js app locally - connecting to same database

余生长醉 提交于 2019-12-25 09:40:15

问题


Is it possible to run an Azure Node.js App Service locally, but connect to the same cloud SQL database?

If so, when connecting to the locally running service, how do you connect a client to the local service? Assuming a client is connecting via an HTML/javascript app, the normal code would be client = new WindowsAzure.MobileServiceClient('https://myservice.azurewebsites.net'); <-- do you just change that url to the IP the local server is running on?


回答1:


Yes, it is possible to get an Azure Mobile App running locally.

You just need to pull the repo from Azure to your local, and then run npm install command under the root folder (which includes package.json file). After all npm packages are installed you should run the following command to start the local Node.js server:

set SQLAZURECONNSTR_MS_TableConnectionString=<mssql_connection_string>&& node app.js

Now, on the client side, change your connection reference to something like this:

client = new WindowsAzure.MobileServiceClient('http://localhost:3000');

and change the CSP HTTP header as below from the index.html:

<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: http://localhost:3000; style-src 'self'; media-src *">

For more information, please refer to https://shellmonger.com/2016/04/01/30-days-of-zumo-v2-azure-mobile-apps-day-2-local-development/



来源:https://stackoverflow.com/questions/46950519/running-azure-node-js-app-locally-connecting-to-same-database

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