0

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.stack.imgur.com/OuYfQ.png

Aravinda
  • 11
  • 4
  • Could you share your build pipeline? You can visit "https://{srcWebApp.Name}.scm.azurewebsites.net to check if the app files are deployed to the right place on the server. – Levi Lu-MSFT Feb 18 '20 at 08:24
  • I have attached the screenshot of pipeline in my question. Also i am able to see the deployed files in "/home/site/wwwroot" path. Please check and suggest. – Aravinda Feb 19 '20 at 04:57
  • Hi @Aravinda Did you checkout below answer? Did it work out by specify below startupcommand? – Levi Lu-MSFT Feb 24 '20 at 15:50
  • Hi @Levi, Thanks for the reply. It worked i was able to access the front-end part using the url. But when i tried to host this app on 443 port it was not working. As azure web app only have 80 and 443 ports exposed to public I need to host this front-end part on 443 port so that it will connect with back-end with 80 port. – Aravinda Feb 26 '20 at 04:18
  • The solution I got from microsoft azure tech is that "we need to have a dynamic entry file as azure linux webapp does not host static websites". – Aravinda Feb 26 '20 at 04:21
  • Could you post your solution as answer? So that it can help others who encounter this same issue. – Levi Lu-MSFT Feb 26 '20 at 05:59
  • @Levi, Issue is not yet resolved completely. As mentioned above I am not able to host it using 443 port. Once issues are resolved I will post the solution. – Aravinda Mar 02 '20 at 08:13
  • @Levi, Could you please explain how npx is different from ng? – Aravinda Mar 13 '20 at 08:50

3 Answers3

0

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

Levi Lu-MSFT
  • 18,505
  • 1
  • 12
  • 19
0

@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.

Aravinda
  • 11
  • 4
0

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