Reputation: 735
I'm trying to deploy an Angular CLI app to Azure App Service on Linux OS, using Azure Dev Ops - but no success. I get Image 1. No error in the server or application logs.
This is what I done so far:
I have the suspicion that I need to kickstart the angular by feeding some time of command when doing the deployment. I have tried running "ng serve --host 0.0.0.0" but that didn't work.
Upvotes: 4
Views: 3754
Reputation: 621
Check the Azure App Service > Linux section on this page. Essentially, you have to serve the app.
Add npx serve -s
in the App Service Configuration > General Settings > Startup Command
In addition to the Azure Web App setting (above), you can also execute the startup after a deployment. If you are using Azure Pipelines, you'd kick it off with something like:
- task: AzureRmWebAppDeployment@4
displayName: 'Deploy website'
inputs:
azureSubscription: '[your Azure subscription]'
appType: webAppLinux
WebAppName: '[your Azure web app]'
packageForLinux: '[artifacts]/package.zip'
StartupCommand: 'npx serve -s'
2023 UPDATE: you no longer need to configure this with a ecoysystem.config.js
PM2 file in the root directory, with this inside as originally answered.
module.exports = {
apps: [
{
script: "npx serve -s"
}
]
};
Old reference: https://burkeholland.github.io/posts/static-site-azure
Upvotes: 9
Reputation: 151
I had the same problem on Azure App Service with Linux and Node, solved it using below startup command
pm2 serve /home/site/wwwroot --no-daemon --spa
Upvotes: 0
Reputation: 6614
I had to give the npx serve -s
as the startup command
Then set the Runtime Stack
with node framework 10.16 (NODE|10.16)
. See below
Then everything started working.
Upvotes: 4
Reputation: 1094
When using Linux App Service container, you may also select PHP stack containing Apache2 Server. Since, Angular files are static ones (JS, CSS, HTML), so you just need some web server to serve this content.
Upvotes: 1
Reputation: 121
If you still want to use App Service - Web App you can just the Windows OS instead of Linux.
Here are the parameters I Used:
Since the output of building angular is a static web app, IIS will serve the site right away.
Upvotes: 1
Reputation: 735
There is a subtle and big difference between the Linux and Windows App service: IIS - which in Windows is actively looking to serve any app, whereas in Linux you have to spin up something on your own to serve it - Express for example.
After some research I discovered that I don't need a full App service dedicated to run a static app (such as Angular or React). It can be done just as efficiently and much cheaper with something like Storage. -> https://code.visualstudio.com/tutorials/static-website/getting-started
Upvotes: 0
Reputation: 828
If you look at the default 'Deploy Node.js App to Azure App Service' release template, it uses the 'Deploy Azure App Service' task and adds the following commands to the task. this might help you out.
Upvotes: 0