Aravinda
Aravinda

Reputation: 11

not able to deploy nodejs with angular app into azure web app using azure devops

I am trying to create a pipeline for the MEAN stack application in azure DevOps. The frontend part is built using nodejs with angular and the backend is built using nodejs with express.

1) After deploying the frontend nodejs project into azure Linux web app built on nodejs stack using azure DevOps, while trying to access the app through URL i am redirected to the default node page instead of my application. But when I deploy the same app using the same pipeline on windows web app built on asp.net I can access the application using the URL. Logs also show that "deployment is successful and ready to serve", is there any changes should be made to access the application deployed in Linux web app?

2) If I deploy both front-end and back-end in different web apps, whether relevant URL modifications in the code is enough or do I need to set any connection strings to establish a connection from front-end to back-end.

Link to screenshot of build pipeline yaml file provided below: https://i.sstatic.net/OuYfQ.png

Upvotes: 0

Views: 1168

Answers (3)

Shivinder Singh
Shivinder Singh

Reputation: 151

Use the following command as startup on Linux machine or App service

pm2 serve /home/site/wwwroot --no-daemon --spa

wwwroot should have all the files generated with ng build --prod command

Upvotes: 0

Aravinda
Aravinda

Reputation: 11

@Levi, Thanks for the above suggestion. I used the command which you gave above "npx serve -s" as the startup command in the release pipeline and it worked for me to deploy and access my application over the internet. If i don't use any command it was routing to default node page.

Upvotes: 0

Levi Lu-MSFT
Levi Lu-MSFT

Reputation: 30343

You reproduced above scenario at the first time. But when i added a startupcommand `npx serve -s, my angular app is successfully displayed. please refer to below example:

- task: AzureRmWebAppDeployment@4
  displayName: deploy
  inputs: 
   azureSubscription: 'mysubscription'
   appType: webAppLinux
   webappName: 'angularlevi'
   deployToSlotOrASE: true
   ResourceGroupName: mygroup
   packageForLinux: dist/angularapp

   StartupCommand: 'npx serve -s'

Or you can add the startupcommand from your app service on the azure portal. Then Click Save --> Refresh. You app should be able to displayed then.

enter image description here

Upvotes: 0

Related Questions