简体   繁体   中英

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?

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 (eg 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 eg using Kudu.

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 (eg 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM