Azure Deployment Issue: Puppeteer Chrome Browser Not Found (Functions Correctly in Local Environment)

I have a Node.js application that uses Puppeteer for web scraping and screenshot generation. Everything works great when I run it on my development machine, but after pushing it to Azure Web App, I’m getting browser not found errors.

The Problem:
When the app tries to launch Puppeteer on Azure, I get this error:

Unable to locate Chrome browser (version 131.0.6778.85). This error occurs when:
 1. Browser installation was not completed before script execution (try running `npx puppeteer browsers install chrome`) or
 2. Cache directory path is misconfigured (current path: /root/.cache/puppeteer).
Refer to configuration guide at https://pptr.dev/guides/configuration for troubleshooting.

My Current Setup:

  • Local development: No issues at all
  • Azure production: Browser detection fails

Code Implementation:

app.get("/api/capture", async (req, res) => {
  try {
    const websiteUrl = req.query.site || "https://google.com";
    
    console.log("Initializing browser instance...");
    
    const browserInstance = await puppeteer.launch({
      headless: true,
      args: [
        "--no-sandbox",
        "--disable-setuid-sandbox", 
        "--disable-dev-shm-usage",
        "--single-process",
        "--no-zygote"
      ],
      executablePath: process.env.CHROME_EXECUTABLE_PATH
    });
    
    console.log("Browser initialized successfully");
    
    const newPage = await browserInstance.newPage();
    console.log("Loading website:", websiteUrl);
    
    await newPage.goto(websiteUrl, { waitUntil: "networkidle2" });
    console.log("Website loaded, capturing screenshot");
    
    const imageBuffer = await newPage.screenshot({ encoding: "base64" });
    console.log("Screenshot captured, cleaning up");
    
    await browserInstance.close();
    
    res.send(`<img src="data:image/png;base64,${imageBuffer}" />`);
  } catch (err) {
    console.error("Screenshot API error:", err);
    res.status(500).json({
      error: "Screenshot generation failed",
      details: err.message,
      trace: err.stack,
      chromePath: process.env.CHROME_EXECUTABLE_PATH || "Path not configured"
    });
  }
});

GitHub Actions Workflow:

name: deploy-web-app

on:
  push:
    branches: [main]
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest
    
    steps:
      - uses: actions/checkout@v4
      
      - name: Setup Node.js
        uses: actions/setup-node@v3
        with:
          node-version: "22.x"
          
      - name: Install packages
        run: npm ci
        
      - name: Configure Puppeteer
        run: |
          npm remove puppeteer-core
          npm add puppeteer
          npx puppeteer browsers install chrome
          echo "CHROME_EXECUTABLE_PATH=$(node -e 'console.log(require("puppeteer").executablePath())')\

azure web apps restricts filesystem access, so puppeteer’s default cache paths won’t work. set puppeteer_cache_dir to /tmp in your app settings and add ‘–disable-extensions’ to launch args. double-check that the chromium binary actually made it to production - i’ve seen builds succeed but files get dropped during deployment.

I had a similar problem with Puppeteer on Azure Web Apps. The native Chrome browser isn’t pre-installed, and even if you install it during the build phase, it may not be available at runtime. I found success using puppeteer-core paired with the @sparticuz/chromium package, which is optimized for serverless environments. This package provides a tailored Chromium binary that works well with Azure’s constraints. Be sure to adjust the launch configuration to use the path for this Chromium executable instead of a local Chrome installation. Additionally, increasing your Azure Web App memory settings can help, as Puppeteer requires a decent amount of resources to operate efficiently. Lastly, do note that file permissions differ on Azure compared to your local machine, which could affect access to the cache directory.

Had this exact problem when I deployed my scraping service to Azure. Azure Web Apps has read-only filesystem restrictions, so Puppeteer can’t download and cache Chrome at runtime. I switched to Azure Container Instances instead - gives you way more control over the environment. If you’re stuck with Web Apps, set PUPPETEER_SKIP_CHROMIUM_DOWNLOAD to true and use Chrome for Testing instead. Here’s another gotcha: GitHub Actions builds on Ubuntu but Azure Web Apps runs Windows by default. Make sure your deployment target matches your build environment, or that executable path from the build won’t exist in Azure.