How do I updated my Azure Web App from Node 14 to Node 20?

Dejan Srdjevic 0 Reputation points
2025-01-05T12:47:48+00:00

I am needing to update my Azure Web App to run on Node 20. It is currently running on Node 14. I am having issues doing this.

Locally I am running Node 20 (which works) and on Azure my Azure Web App server has is using Node 14. I need to update node in Azure to Node 20 as some packages require at least Node 18 to run. However, when I try to update my Azure Web App configto 20 it doesn't take. My WEBSITE_NODE_DEFAULT_VERSION is set to ~14. I update it to ~20 and start getting ambiguous IIS errors on the server. I am also using a .yml file for my CICD through GutHub Actions and have updated the Node build settings for Node to 20.x (attached here). This is still throwing ambiguous IIS errors when buiding. I am also using a web.config.

Are there any steps I'm missing? What should I be doing to update Node in Azure from 14 to 20?

# 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 - dedaai-server

on:
  push:
    branches:
      - main
  workflow_dispatch:

jobs:
  build:
    runs-on: windows-latest

    steps:
      - uses: actions/checkout@v2

      - name: Set up Node.js version
        uses: actions/setup-node@v1
        with:
          node-version: '20.x'

      - name: npm install, build, and test
        run: |
          npm install
          npm run build --if-present
          npm run test --if-present
      
      - name: Upload artifact for deployment job
        uses: actions/upload-artifact@v4
        with:
          name: node-app
          path: .

  deploy:
    runs-on: windows-latest
    needs: build
    environment:
      name: 'Production'
      url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

    steps:
      - name: Download artifact from build job
        uses: actions/download-artifact@v4
        with:
          name: node-app

      - name: 'Deploy to Azure Web App'
        uses: azure/webapps-deploy@v2
        id: deploy-to-webapp
        with:
          app-name: 'dedaai-server'
          slot-name: 'Production'
          publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_C67A4A2332FC400A98E4C5FFECB4FAC8 }}
          package: .
Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
1,056 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Laxman Reddy Revuri 1,755 Reputation points Microsoft Vendor
    2025-01-20T09:28:52.42+00:00

    Hi @Dejan Srdjevic
    The WEBSITE_NODE_DEFAULT_VERSION conflict occurs when changing to Node.js 20, which may cause compatibility issues with your web.config or app dependencies, especially with the run.cjs path in production. Change run.cjs to your app’s main file (e.g., index.js). Example

    web.config: <configuration> 
      <system.webServer> 
        <handlers> 
          <add name="iisnode" path="index.js" verb="*" modules="iisnode"/> 
        </handlers> 
        <rewrite> 
          <rules> 
            <rule name="DynamicContent"> 
              <conditions> 
                <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/> 
              </conditions> 
              <action type="Rewrite" url="index.js"/> 
            </rule> 
          </rules> 
        </rewrite> 
        <httpErrors existingResponse="PassThrough" /> 
      </system.webServer> 
    </configuration>  
    
    1. Use Kudu console and run npm cache clean --force, then restart your app.
    2. In Azure portal, enable Application Logging and Detailed Error Messages under Diagnose and Solve Problems.
    3. Run locally with NODE_ENV=production to ensure compatibility.
    4. Run npm install, npm outdated, and npm audit fix to update packages.
    5. Ensure no conflicts exist in your GitHub Actions workflow and enforce Node.js 20 with:
    az webapp config set --name <your-app> --resource-group <your-resource-group> --linux-fx-version "NODE|20"
    

    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.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.