Node.Js Express 4 Application in Visual Studio 2017 and Azure Web Apps

I’ve been playing with Node.js for one of our clients and this happened to be at the same time with Visual Studio 2017 release, so I though…

Node.Js Express 4 Application in Visual Studio 2017 and Azure Web Apps

I’ve been playing with Node.js for one of our clients and this happened to be at the same time with Visual Studio 2017 release, so I though I’d give it a try with the new Visual Studio see what are my options there.

So to start with looks like there are few templates in Visual Studio to build Node.js apps, with both TypeScript or JavaScript options.

You also have the choice of making it an Azure Node.js web app (which is what I’m interested in) or a normal Node.js web app.

Also you have the option to include Express package to it or not, which I will go with Express package for this demo.

About hosting in Azure, the application will be hosted in a normal Azure Web App, and will use iisnode for processing the requests.

The following picture shows are all the options you got for Node.js apps and I pick the one that says: “Basic Azure Node.js Express 4 Application (TypeScript)”

Node.js project templates in Visual Studio 2017

That’s basically it, now you can just press F5, just like any .Net application, and it will run the app in the browser for you with all the break point, debugging features, etc.

Now, here comes the hard part, to deploy this to Azure.

Nah, jokes, jokes, that’s the easiest part. Just right click on the project and click on “Publish”.

And follow the standard stuff that you do for Publishing a normal .Net Web Application or Web Service to Azure, like selecting your Azure Subscription, Service Plan, App name etc, and click “Publish”.

This will compile your TypeScript file, and get all the js files needed from your node_modules and publish them all to your Azure Web App for you.

And here is our Node.js app running on Azure:

Cheers!