user3175088
user3175088

Reputation:

Deploy node.js server and angular app to azure web service

I have an Angular app (9.1.4) and a node.js server application (12.14.1). My files are currently configured like this:

MyApp
- package.json
- angular.json
- server
  - server.js
- src
  - app
  - asserts
  - environments
  - angular html/css/ts
- node_modules

In order to runt his locally I have to run node server.js in one cmd prompt and ng serve in another. I hope to deploy this project to Azure but am not sure how to set this up so that it can run in a single app service. So:

  1. How do I run the server (node.js) and the app (angular) via the same command locally?
  2. Once I have this setup locally, what (if anything) needs to be changed in order to run in Azure?

Upvotes: 1

Views: 1176

Answers (1)

Jason Pan
Jason Pan

Reputation: 21949

First of all, are the startup ports of your project, front-end angular project and back-end node service in the same configuration file?

  1. If yes, then you can execute multiple commands by modifying the script in the package.json file.

  2. Because only 443 and 80 ports are supported in azure web app. If the port configuration of the two projects is not the same, it may run normally locally.

For example, the ng project is 7001, and the server project is 7002, deployed to the azure web app, according to the process.env.PORT parameters, it will the port conflicts and the project cannot be started.

So if it is the second case, how to deal with:

You can use virtual applications to deploy your applications separately. For more details, you can see my answer in another post.

Upvotes: 0

Related Questions