Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
Hi Habiba Asif,
The next: not found error occurs because node_modules is excluded from the deployment zip, and Azure's npm install --production may miss critical dependencies for Next.js.
Please try the updated code below.
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions
name: Build and deploy Node.js app to Azure Web App
on:
push:
branches:
- main
- payment
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Set up Node.js version
uses: actions/setup-node@v3
with:
node-version: '22.x'
- name: npm install and build
run: |
npm ci
npm run build
- name: Create deployment package
run: |
# Remove dev dependencies but keep the built app
npm prune --production
# Create zip with all necessary files including node_modules
zip -r release.zip . -x "*.git*" "*.github*" "*node_modules/.cache*"
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v4
with:
name: node-app
path: release.zip
deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: 'Production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
permissions:
id-token: write
contents: read
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: node-app
- name: Unzip artifact for deployment
run: unzip release.zip
- name: Login to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_F897BD80 }}
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_D28DA4E6 }}
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_C932F75D3F1C41E9A6 }}
- name: 'Deploy to Azure Web App'
id: deploy-to-webapp
uses: azure/webapps-deploy@v3
with:
app-name: 'my-app-name-qa'
slot-name: 'Production'
package: .
Made key changes to improve deployment, replaced npm install with npm ci for consistent installs, added npm prune --production to strip dev dependencies, updated the zip command to include node_modules, and removed the test step to streamline the process.
Please accept as "Yes" if the answer provided is useful, so that you can help others in the community looking for remediation for similar issues.