Search code examples
angularazuredockerdeploymentazure-pipelines

Can't get deployed Angular application to run in Azure Web Service


I've followed this blog trying to deploy my Angular app to Azure App Service. It seems to work, the build takes place and the rollout happens as supposed to (as far i can tell). However on the start, I get "Application Error" and the following log appears in the console.

2024-04-10T19:52:27.081Z INFO  - Starting container for site  
2024-04-10T19:52:27.083Z INFO  - docker run -d --expose=8080 --name app-puf-gui-dev_0_910ed413 -e WEBSITE_USE_DIAGNOSTIC_SERVER=true -e WEBSITE_SITE_NAME=app-puf-gui-dev -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=app-puf-gui-dev.azurewebsites.net -e WEBSITE_INSTANCE_ID=94e1cb8215dce9f31465132c8957e6ec3ef6a14c876f2c4d8780bfb99d805518 appsvc/node:20-lts_20240207.3.tuxprod pm2 serve /home/site/wwwroot -no-daemon-spa  
2024-04-10T19:52:27.084Z INFO  - Logging is not enabled for this container.Please use https://aka.ms/linux-diagnostics to enable logging to see container logs here.  
2024-04-10T19:52:28.525Z INFO  - Initiating warmup request to container app-puf-gui-dev_0_910ed413 for site app-puf-gui-dev  
2024-04-10T19:52:34.770Z ERROR - Container app-puf-gui-dev_0_910ed413 for site app-puf-gui-dev has exited, failing site start  
2024-04-10T19:52:34.786Z ERROR - Container app-puf-gui-dev_0_910ed413 didn't respond to HTTP pings on port: 8080, failing site start. See container logs for debugging.  
2024-04-10T19:52:34.799Z INFO  - Stopping site app-puf-gui-dev because it failed during startup.  

The build pipeline follows (roughly) this setup, except I only target a single environment. I've been googling, reading and trying to get some traction but I realize that I'm stuck not being able to diagnose it further. As far I can confirm, the issue is with the hosting that serves the application. But how/why - I have zero clue.

I have narrowed it down to those two lines. At the first one, it's still all good, at the next one, we're done.

  • Initiating warmup request to container app-puf-gui-dev_0_910ed413 for site app-puf-gui-dev
  • Container app-puf-gui-dev_0_910ed413 for site app-puf-gui-dev has exited, failing site start

How do I troubleshoot it more?


Solution

  • I've found the reason in my particular case to be a typo on the execution path in Azure. The (almost perfect) source is this great article, with the only flow that the mentioned flag got distorted in rendition saying pm2 serve /home/site/wwwroot -no-daemon-spa.

    It should be:

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