Having trouble deploying to Azure App Service

System Information
  • Strapi Version: 4.1.8
  • Operating System: Windows
  • Database: MySql
  • Node Version: 14.18.1
  • NPM Version: 6.14.15
  • Yarn Version:

Hello,

As a proof of concept, I’m trying to deploy Strapi to an Azure app service and I can’t seem to get it working. I’m hoping someone has run into this or can point me in the right direction.

TLDR; the deployed quickstart app to an Azure app service is returning a 500.1001 error with no information in the application logs.

Starting from the quickstart project, I followed the guide I found here, although I had to make some adjustments. Here’s what I have done so far:

  • Originally I had selected Linux for the OS of the app service. I had set up my app service to be deployed from a git repository in AzDO, but when the deploy ran, it encountered a bunch of timeout errors when trying to build. I saw reference to this in another post on the forums but I didn’t see any resolution. I created a new app service with Windows as the OS and this seemed to have allowed it to grab the needed modules.
  • This subsequently failed with a message that strapi was not recognized as a command. I updated the “scripts” property of package.json to be: "strapi": "node node_modules/@strapi/strapi/bin/strapi.js start". This is a slightly different path from what is in the guide here. I don’t know if this was correct, but this is where I found the strapi.js
  • The git deployment automatically creates a web.config file which is looking for a server.js I had to add a server.js file at the root which is covered in the deploy documentation
  • At this point I tried browsing to https://.azurewebsites.net/ and got an error about not being able read a config due to the sharp library. I tried several things to resolve this using the kudu console including trying the notes in the error message: npm install --platform=win32 --arch=x64 sharp. Eventually I deleted the node_modules folder, deleted the package.lock and then running npm install.
  • Calling the endpoint again resulted in an error and from the app service logs I could see an error about config values being blank. I basically took the values from the .env file and added them as app settings in the app service and then added the database connection information as app settings
  • Now when I browse to the app service url, I can see what I think is the node app starting up in the logs; I see the message that says One more thing...Create your first administrator 💻 by going to the administration panel at: . . . But nothing else shows in the log and in the browser a 500.1001 error is returned. According to the Microsoft docs, a 1001 sub error means that the app is not responding on the url.
  • Since the HOST value was 0.0.0.0 I tried updating this to the app service host instead, but this didn’t change anything. I instead updated the config/server.js to include a url property that had the url of the app service and reverted the HOST value back to 0.0.0.0.
  • Based on the error message I thought something might be wrong with the port, which I left as the default 1337. I searched for some answers and saw for other node apps that valid ports are 80 and 443, but when I tried setting the environment variable to either for these values I got a permission denied error in the logs when the app tried to start up and ended up switching the PORT value back to 1337.

At this point I’m pretty stuck. I’ve turned on verbose logging on the app service, but I’m not seeing anything in the logs beyond the startup message and app insights doesn’t have anything. It “seems” like the node app is running but for whatever reason the request is getting to the app. I know that the environment variables/app settings are being read since I can change them to invalid values and get different error messages.

Any help would be appreciated, thanks!


1 Like

I am stuck with the same issue. Can anyone help out?

I’m facing the same issue on Azure Web App

An error has occurred during web site deployment. Source code is already deployed to Azure properly, but when the docker starts, it failed with these error messages

2023-08-15T10:22:12.481214964Z PATH=“$PATH:/home/site/wwwroot” yarn start
2023-08-15T10:22:17.560255145Z yarn run v1.17.3
2023-08-15T10:22:18.248003266Z $ strapi start
2023-08-15T10:22:18.535420585Z /home/site/wwwroot/node_modules/.bin/strapi: 1: …/@strapi/strapi/bin/strapi.js: not found

I used FTPS to check and the file …/@strapi/strapi/bin/strapi.js is already there.

Is there anyone solved this issue?

I have to manually run npm install mysql and npm start on the ssh in kudu, it runs fine, i can see the admin dashboard and i can log in with the credentials i created. But after an hour of without usage, the app will restart and I have to run npm install, npm start again. Why is it not persisting? What am I missing?

Anyone successfully deployed this into azure web app service?

I have posted my notes on the steps I needed to take to get this working