1

I'm developing a simple site consisting of an Angular frontend and a simple NodeJS backend. I currently see 3 ways to setup the project:

  • have 1 Web App to serve the static HTML and 1 Web App for the NodeJS backend
  • serve both REST API and static files using the same NodeJS instance
  • I read about virtual directories for Azure Web Apps, but wasn't able to find appropriate documentation. Is that even a viable solution?

What's the standard setup to use for Azure? Is there any in-depth documentation I missed?

Michael
  • 1,347
  • 1
  • 13
  • 27

1 Answers1

3

I would say that this is a type of question for which it is difficult to get an answer, because someone could write an entire book on this topic and a lot of aspects are a matter of personal preferences, approaches and so on.

Before I try to attempt a first answer I would like to point out that I am not familiar with Node.js at all, but I am fairly familiar with Azure AppService and ASP.Net Core MVC.

There is no standard setup in Azure AppService (websites in this case) and in fact all the 3 options that you mentioned are valid. Based on my expperience with Azure AppService I would say that option one is suitable when you have a publicly available API. In that case you could also register your API with Azure Management API.

The second option is, in my opinion, best suitable when your frontend is the only consumer of your API.

The third option is not that common, but 100% possible. Here is a very good article on how to set virtual directories up and how to deploy an application to them using Visual Studio. I am not sure how this would be done exactly with the tooling at your disposal, but conceptually it should be possible. However, deploying NODE.js projects in virtual directories could cause some problems you should be prepared for. More information here.

I would however stick with what I said in the start: I would deploy both backend and frontend to the same web app if my Angular application is the only consumer of the API and I would deploy to 2 different web apps if my API was public.

I'm curious what other might think in this regard.

Community
  • 1
  • 1
Dan
  • 166
  • 6
  • 2
    Don't know why the question is getting so many down votes. It's a perfectly valid question. I don't know about virtual directories, but I think your comments are valid about 1 vs 2 web apps. Having a public API does not necessarily mean 2 web apps is preferable, though it's worth considering. What you really want to ask yourself is, does my API need to be available even if I want to take down my site for awhile? Then two web apps is good. Otherwise, one web app does the job quite well. A statically served site with angular on the front end and node on the backend does quite well! – Sam May 13 '17 at 22:02
  • I was thinking the same more or less, but expressed it a little bit different. However, using virtual directories is something I would only recommend as a last resort, even if it should be possible, as mentioned in the answer. P.S. I also don't know why you got down votes :( It wasn't me :) – Dan May 13 '17 at 22:10