Why can't I access my Azure website after successful deployment - node.js

I build a website with React and I deployed it on Azure. I build it and then deployed the build folder with vs code on Azure. The process is actually very easy using VS Code and the Azure extension. It is explained well here.
So far so good, everything worked fine. Now I needed to deploy the same app (the same build folder) but in another webApp. Basically, I needed to have separate versions of the app. So, I did the same things I did the first time (create webapp on Azure -> deploy with VS Code). However, I can't see my website when I go to the url. All I see is the default generated webapp, which is a dummy html page.
It looks something like this:
Hey, Node developers!
Your app service is up and running.
Time to take the next step and deploy your code.
I am seeking to understand this: I deployed the same build folder. I didn't change anything. I can't see my website (I thought it may take some time but I waited for nine hours now)
Things I've tried:
deploy again and again
restart the app on azure
stop and rerun the app on azure
go to the URL on incognito mode
I searched a lot and I've seen some answers that it can be about some path or file in the Azure configurations. However, I don't have anything in my configurations. Here are screenshots of my app configurations on Azure
here is my app configurations (when I go to configurations on Azure)
and these are the general configurations/settings
here is the deployment slots:

The message you are getting is the standard message when the app service is created but nothing is deployed.
Possible explainations are:
the app is being deployed to a different site
the app is being deployed to the same site but a different slot
the deployment is failing
your application is not listening on the port provided by the PORT environment variable

Recently I got into same issue,
Check you node version in package.json. I used this,
"engines": {
"node": "^12.16.3"
}
Azure web service was on Linux server. Startup commnand required in Azure General Settings -> Stack Settings
pm2 serve /home/site/wwwroot --no-daemon
You can also look at the log metrics after deploying or start the service. It will provide you info on the issue.

Related

NestJs deployed to Azure Linux Web App wont start

I have spent many days but still can not get this to work.
I have setup a deployment pipeline for NextJS I have the dist folder and I'm also copying the node modules folder etc. The build pipeline works, makes a package which is then deployed to a Azure Linux Web App.
Problem is can not hit the application
I look into the logs and I can see the app has started but for some reason the container fails and the site never works.
I'm pulling my hair out here I have tried everything, read every guide I can find but nothing seems to work. Help me stack-bi-wan-overflow your my only hope.
As you have confirmed in your comment , Converting this to answer to help other community members.
To achieve the above requirement make sure that you have used express instead of using fastify . As fastify must have different network configuration which can not connect with container.
For more information please refer the below links:-
SO THREAD: nestjs to azure windows app service - web.config settings & Angular CLI app not running when deploying to Linux App Service
Blog:- Deploy and run Nest js app to azure

How do you host Strapi within an Azure App Service?

After inheriting a Strapi application hosted on Azure Container Instances, which has proved temperamental.
Given it's on the surface just a Nodejs application we want to move it to an Azure App Service to take advantage of hosting savings and also deployments via slot swapping.
The current documentation for Strapi includes guides for both Azure VM and deploying as a Docker conatainer. However we want to host as code on a windows based app service.
The reason for windows over linux is the time that Zip Deploy or Web Deploy taken when running on the linux version. Also we can run the App in an existing App Service plan.
The question is how to host Strapi on an Azure App Service?
After much trial and error we finally have this up and running, here are the steps that made it successful.
Create the App Service
Create an App Service that publishes "code", has a runtime of Node 14 LTS & has OS of Windows.
Configure the App Service platform
Once created navigate to "Configuration" of the App Service and make sure that WEBSITE_NODE_DEFAULT_VERSION is set to "~14". And on the "General Settings" tab update the platform to "64 bit". This ensures that the "sharp" package that is used by Strapi can run, as it requires 64 bit platform.
After making these changes, navigate to the console and run the command node -p process.arch you should see the result is result is "x64".
Application Settings
Now to configure your application specific settings. For an out of the box Strapi app this is likely to include database configuration and any plugins like mail, identity and storage providers.
For us the crucial part though was the settings to be used by Strapi to startup and host the application.
This include the HOST & PUBLIC_URL settings.
HOST = 0.0.0.0 and PUBLIC_URL = https://{APP_NAME}.azurewebsites.net/ (replace APP_NAME with the name of your app).
Code changes
There are a few changes needed to the out of the box Strapi app that are needed to run on Azure.
Add a web.config to the route of the project. An example can be shown here: https://gist.github.com/bradleyisfluent/1033bb9dc908b2386c5ee09e0b36409f. This utilises IISNode to run server.js as the entry point to the app.
Create a server.js in the root of the project. Contents should look like:
const strapi = require("strapi");
strapi().start();
Modify the current server.js within Strapi config /config/server.js to access the environment variables on the server, like this:
host: process.env.HOST,
port: process.env.PORT || 3000,
n.b of course here, we are simply accessing environment variables and configuration it can be managed in different ways. The crucial thing though is to access the port via process.env.PORT which is implicitly set on the App Service.
Deploy code
This is where we are still a little bit of a work in progress. Utilising Azure Devops pipelines we are building and deploying the application.
It appears that using "Run From Package" feature of Azure App Service doesn't not work for Strapi. My hypothesis is something is trying to write to the wwwroot dir which is read-only in the this setup and this causes an error.
So we are using "webDeploy" which given the size of our built project (218mb, thanks node_modules) means the deployment times are slow. However this only applies to our preview builds as we can use slot swaps to release to Production.
Here is a link to a slightly reducted version of a working azure-pipelines.yml: https://gist.github.com/bradleyisfluent/ffff8c1b6bedd5052274dc0d9f19a91d

Azure App Service suddenly delivers file directory overview instead of Angular App

I have an Azure Web App (WebAppLinux) running an Angular application. The deployment is based on the Azure WebApp#1 task in an Azure pipeline.
Everything was fine until today. Without anyone having done a deployment, the website only shows an index page with the files stored in the home directory.
A re-deployment through the CI/CD pipeline is still successful. However, the error remains.
Was there any change to the Azure App Service that made my application incompatible?
The answer of LuisDev99 in https://stackoverflow.com/a/61707805/3809334 has solved the problem.
We had to add
pm2 serve /home/site/wwwroot --no-daemon --spa
to the Startup Command under Configuration, select the tab -> General Settings
In the past we had a startup script that called npx serve -s within our Angular application.
It seems that this way did not work anymore over the weekend. Maybe because there was a configuration change in the WebApp by Microsoft
Not an answer, but if you file an issue in https://github.com/Azure-App-Service/Linux/issues, that will help proceed with the next steps for investigation.

Deploy vue.js Quasar App with Azure Portal

I am trying to deploy my Quasar app through Azure Portal. I have created a web app service, connected my github repo through the Deployment centre, and ran the build and deploy github workflow successfully (note: my npm run build calls quasar build which the Quasar docs describe). When I use FileZilla to access my server, I see my entire app along with the dist/spa folder under site/wwwroot so I believe the build worked correctly. Unfortunately, when I try to access my app through the browser, I am welcomed with the default Azure webapp page rather than my app.
Default Azure WebApp Page
I am unsure why my files are not being served. I have deployed a very simple Nuxt.js app in the past using the same approach and managed to deploy it relatively quickly. Perhaps nuxt.js does something under the hood that I am not aware about.
Any leads will be greatly appreciated.

Azure Continuous Delivery - How to deploy a folder to an App Service?

I'm pretty sure i am doing something wrong.
But let me attempt to explain my situation...
I created an Azure App Service with Continuous Delivery configured. So far i see that all my deployments are successful. When i go to my app service URL i see Service Unavailable.
Now i suspect my problem could be related to what is being deployed.
Note that I am using Visual Studio Online for my source control and build system.
The source/repo only has 3 folders:
- A folder called .vscode
- A folder called Tools (a bunch of .net console apps)
- A folder called Service (my node.js based service)
Now, the source builds successfully.
And the continuous deployment, triggered after a queued build, completes successfully.
But when i go to the service url i see the dreaded message "Service Unavailable".
I suspect the problem is related to this:
Basically im not sure what is being deployed here.
What i want to deploy is just the Service folder (my node.js app).
I suspect somehow that the entire source tree is being deployed.
Some additional details:
Http Protocol: HTTPS
Error: 503 - Service Temporarily Unavailable
Any help/insights are much appreciated!
Updates
I am confused if the Continuous Delivery option can deploy the node.js app. I did come across this article which shows how to deploy node.js app via "Push to Azure from Git".
Updates 2
I'm not entirely sure right now because i havent tried this out. But the answer to this question seems to hold the key (it seems like it is exactly what im looking for).
Updated 3
I was able actually get the node.js app to start. The issue was that the .js file is two folders deep (in the Service folder). I updated the "Startup command" setting under the "Deploy Azure App Service" (under Continuous Delivery build definition). Now i can see (from the Kudu Docker logs) that it is running.
The problem im having now is that the node.js app can't seem to conenct to the Azure SQL database (this works when i run locally).

Resources