I created a Web App in Azure to host an angular application. I selected the runtime as bellow:
But my local setup details:
I used Anguler cli to create the application and then I ran ng build --prod to create the dist. Then I tried following methods to deploy the Angular app to Web app: 1. Used Azure App Service extension in VS Code 2. FTP using FileZilla with the ftp details from the Web app's deployment center.
But when I brows the url: https://eventzweb.azurewebsites.net/ I see the following page but not my page from the angular app.
Any idea why this is happening? Why I'm not seeing my page?
Thank you for your help in advanced.
In the Azure portal, search for and select App Services, and then select your app. In the app's left menu, select Configuration > Default documents. To add a default document, click New document. To remove a default document, click Delete to its right.
In the Azure portal, search for and select App services and select the app that you want to move. From the left menu, select Change App Service plan. In the App Service plan dropdown, select an existing plan to move the app to.
Open the VS Code and open the project folder path. In VS code search Azure App Service and install. Before deploying to Azure, we must build our Angular app using the below command which will build the Angular project and will create all necessary files to a dist folder.
Simplest solution:
Go to your app service > Configuration
Under Configuration, select the tab -> General Settings
On the Startup Command field, enter the following command:
pm2 serve /home/site/wwwroot --no-daemon --spa
Now your app should be able to appear instead of the default page.
The reason your app is not running is because it is running on Linux, and Linux does not have a IIS server to handle routes of your node app (it goes something along those lines).
Watch this video, this guy deserves all the credits (go like his video if this saved you): https://www.youtube.com/watch?v=HLhlKIIfaZs
What worked for me, is to have Node 12 runtime + setting the startup script in General settings given by @LouisDev22 (Thanks a lot):
pm2 serve /home/site/wwwroot --no-daemon --spa
and then set the SCM_TARGET_PATH
variable to /home/site/wwwroot
in the Application settings, this variable is only needed if you first run your app service with another runtime.
PS1: You can find the General and Applications settings in the app service Configuration menu.
PS2: Bravo Azure
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With