Create a web app with App Service on Linux – Save yourself hair and time

October 19, 2016, Microsoft announced “Hosting Azure Web Apps on Linux“. Finally I can deploy my Node.js app without running IIS! However, there is one small gotcha that is good to know, unless you want to spend an hour or two troubleshooting… I did, and I just want to share my learning to save you guys some time if you run into the same problem.

Microsoft have a short tutorial on how you set up a web app on Linux, which pretty much covers the basic. My problem was that I could not reach the site after it was set up and deployed. Frustrated, I started troubleshooting and finally resolved it. Here are a few things that I ran into when trying to setup a simple “Hello world”-app in Node.js.

  • Do not use a custom port – it wont work (only port 80 and 443 is accessible).
  • Instead, use process.env.PORT
  • DO NOT use process.env.port – it’s case sensitive!
  • Of course, you can always use classic fallback with process.env.PORT || 1337 (or any given port number).
  • If you begin changing ports: restart the app by pressing “restart” (tools menu under “Overview”). Deployment of a git commit didn’t solve this problem, so just restart the app instead (probably has something to do with caching or similar, e.g needing to do an IIS-reset after manipulating the hosts file in Windows)

So, if you deploy your app but you can’t access it – check your port settings!



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s