0

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 Answer 1

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/

Sign up to request clarification or add additional context in comments.

4 Comments

Just want to confirm that when I follow these steps, my locally running node server will still be connected to my Azure database?
Yes, it will be connected to your Azure database after you set the environment variable SQLAZURECONNSTR_MS_TableConnectionString.
I've actually only finally gotten around to this, and I've hit a snag. I've set the environment variable but I'm getting the error ConnectionError: Login failed for user 'User'. I've checked and checked and I'm sure that I'm using the same SQL login details as the live server. I made sure to add appropriate firewall whitelist to make sure my local server is able to access it (before I did that I was getting a different error). I don't know what's going wrong.
actually I got it to work, made a silly error. THANK YOU AARON

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.