Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running Angular in Azure on a Linux Web App

I've been trying to get my Angular app to run natively on an Azure Linux Web App. The only way I've been able to do it is with Docker, and while that is great, Azure seems to use Docker so I'm running a Docker container inside a Docker container. I'd much rather run the app natively. However, I've been unable to get the app to kick off as I get "ng is not a known command" when I try to serve the app. I don't see a way to get the Angular CLI installed. There is a surprising lack of documentation on this. Has anyone been able to pull this off?

like image 537
Matt M Avatar asked Aug 09 '19 12:08

Matt M


3 Answers

I was able to run Angular 9 on a Linux Web app by choosing PHP 7.3 as runtime stack. I simply build (in DevOps) and deployed the result of my ng build --prod (no neasted folders, just the files) and it worked as PHP can serve my index.html.

You dont have to put any startup command.

I followed this video to make the build, and this one to make the release.

like image 150
Luis Miranda Avatar answered Nov 15 '22 11:11

Luis Miranda


That is not the way to go.

You should use the Angular CLI to compile your project and create your release artifacts (ng build --prod) inside a build pipeline (e. g. Azure DevOps) rather then use it to serve your application on a hosted site. Then within a release pipeline, you will publish the (compiled) artifacts to the Azure Web App.

If you want to do this locally, it is very similar. You compile your project and upload the result e. g. using Kudu.

like image 29
Martin Brandl Avatar answered Nov 15 '22 10:11

Martin Brandl


I ended up abandoning this approach. The short answer is that I need something like Express to serve up the Angular app. However, Azure Blob Storage can be configured to serve up static web sites (e.g. Angular) and is dirt cheap. I'll need to set up Azure CDN to get a custom domain and SSL working, but this is so much easier and potentially much cheaper than the route I was going.

like image 43
Matt M Avatar answered Nov 15 '22 10:11

Matt M