I have created a Dockerfile for Azure Function that build and installs playwright into container. Install all the dependency related to Playwright. I tried with Playwright official image still it was giving same error. So I have installed Playwright CLI globally to install only chromium dependency
Below is a dockerfile
# Base image for Azure Functions .NET Isolated
FROM mcr.microsoft.com/azure-functions/dotnet-isolated:4-dotnet-isolated8.0 AS base
WORKDIR /home/site/wwwroot
EXPOSE 8080
RUN apt-get update -q && \
apt-get install -y -qq --no-install-recommends \
xvfb \
libxcomposite1 \
libxdamage1 \
libatk1.0-0 \
libasound2 \
libdbus-1-3 \
libnspr4 \
libgbm1 \
libatk-bridge2.0-0 \
libcups2 \
libxkbcommon0 \
libatspi2.0-0 \
libnss3 \
libpango-1.0-0 \
libcairo2 \
libxrandr2
# Build stage for the service project
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["FunctionApps/CheckImage/CheckImage.csproj", "FunctionApps/CheckImage/"]
COPY ["Libraries/HealthCheckHelper/HealthCheckHelper.csproj", "Libraries/HealthCheckHelper/"]
COPY ["Libraries/BlobHelper/BlobHelper.csproj", "Libraries/BlobHelper/"]
RUN dotnet restore "./FunctionApps/CheckImage/CheckImage.csproj"
COPY . .
WORKDIR "/src/FunctionApps/CheckImage"
RUN dotnet build "./CheckImage.csproj" -c $BUILD_CONFIGURATION -o /app/build
RUN dotnet tool install --global Microsoft.Playwright.CLI
ENV PATH="${PATH}:/root/.dotnet/tools"
RUN playwright install chromium
# Publish stage for the service project
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./CheckImage.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
# Final stage - Using Playwright .NET image as the base for compatibility
FROM mcr.microsoft.com/playwright/dotnet:v1.51.0-noble AS final
WORKDIR /home/site/wwwroot
# Copy published application files
COPY --from=publish /app/publish .
# Install Playwright dependencies and Chromium
RUN apt-get update && apt-get install -y --no-install-recommends \
&& npx playwright install chromium \
&& npx playwright install-deps chromium \
&& rm -rf /var/lib/apt/lists/*
# Environment variables for Azure Functions
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
AzureFunctionsJobHost__Logging__Console__IsEnabled=true \
PLAYWRIGHT_BROWSERS_PATH=/home/site/wwwroot/.playwright
While running in local it is giving me
2025-04-25 17:58:39 [2025-04-25T12:28:39.800Z] Driver not found: /home/site/wwwroot/bin/.playwright/node/linux-x64/node
2025-04-25 17:58:39 [2025-04-25T12:28:39.801Z] Result: Driver not found: /home/site/wwwroot/bin/.playwright/node/linux-x64/node
2025-04-25 17:58:39 [2025-04-25T12:28:39.801Z] Exception: Microsoft.Playwright.PlaywrightException: Driver not found: /home/site/wwwroot/bin/.playwright/node/linux-x64/node
2025-04-25 17:58:39 [2025-04-25T12:28:39.801Z] at Microsoft.Playwright.Helpers.Driver.GetExecutablePath() in /_/src/Playwright/Helpers/Driver.cs:line 96
2025-04-25 17:58:39 [2025-04-25T12:28:39.801Z] at Microsoft.Playwright.Transport.StdIOTransport.GetProcess(String driverArgs) in /_/src/Playwright/Transport/StdIOTransport.cs:line 116
2025-04-25 17:58:39 [2025-04-25T12:28:39.801Z] at Microsoft.Playwright.Transport.StdIOTransport..ctor() in /_/src/Playwright/Transport/StdIOTransport.cs:line 46
2025-04-25 17:58:39 [2025-04-25T12:28:39.801Z] at Microsoft.Playwright.Playwright.CreateAsync() in /_/src/Playwright/Playwright.cs:line 43
2025-04-25 17:58:39 [2025-04-25T12:28:39.801Z] at CheckImage.ScanImage.CheckImage(HttpRequest req, String scanid) in D:\Projects\Dev-CheckImage\ProjectX\FunctionApps\CheckImage\CheckImage.cs:line 32
2025-04-25 17:58:39 [2025-04-25T12:28:39.801Z] Stack: at Microsoft.Playwright.Helpers.Driver.GetExecutablePath() in /_/src/Playwright/Helpers/Driver.cs:line 96
2025-04-25 17:58:39 [2025-04-25T12:28:39.801Z] at Microsoft.Playwright.Transport.StdIOTransport.GetProcess(String driverArgs) in /_/src/Playwright/Transport/StdIOTransport.cs:line 116
2025-04-25 17:58:39 [2025-04-25T12:28:39.801Z] at Microsoft.Playwright.Transport.StdIOTransport..ctor() in /_/src/Playwright/Transport/StdIOTransport.cs:line 46
2025-04-25 17:58:39 [2025-04-25T12:28:39.801Z] at Microsoft.Playwright.Playwright.CreateAsync() in /_/src/Playwright/Playwright.cs:line 43
2025-04-25 17:58:39 [2025-04-25T12:28:39.801Z] at CheckImage.ScanImage.CheckImage(HttpRequest req, String scanid) in D:\Projects\Dev-CheckImage\ProjectX\FunctionApps\CheckImage\CheckImage.cs:line 32.
It seems it is not taking path of bin/Debug/net8.0. How do I make it such that it finds driver path.

