You are currently using yarn dev
in production, which is meant only for local development. Azure App Service expects a production-ready application, and that's why the deployment is failing.
In package.json
, you need to change the start
script. Right now, it's likely running next start
, which doesn't work properly if you're using the standalone
output mode in Next.js.
Update the package.json
like this:
{
"scripts": {
"build": "next build",
"start": "node .next/standalone/server.js",
"postinstall": "next build"
}
}
next.config.js
should contains this:
module.exports = {
output: 'standalone',
};
Next, update the GitHub Actions workflow. Right now, the startup command in Azure is trying to run yarn dev
, which should be replaced with the proper production start command.
Change this line:
az webapp config set --resource-group "Smartovate" --name "smartovateweb" --startup-file "yarn install && yarn dev --port 8080"
To this:
az webapp config set --resource-group "Smartovate" --name "smartovateweb" --startup-file "yarn install && yarn build && yarn start"
Then the app will build and started in production mode.
You should also check the GitHub Actions zip step includes the necessary build output. If you're using the standalone
mode, zip at least the .next
, public
, node_modules
, package.json
, and yarn.lock
files:
zip -r release.zip .next/ public/ node_modules/ package.json yarn.lock
Push the changes and let the workflow deploy again. The app should now start correctly on Azure. Let me know if you'd like me to adjust your full workflow file with all of this applied.
Hope it helps!
Please do not forget to click "Accept the answer” and Yes
wherever the information provided helps you, this can be beneficial to other community members.
If you have any other questions or still running into more issues, let me know in the "comments" and I would be happy to help you.