Puppeteer works in Azure function app consumption plan but fails in flex consumption

Anupam Dutta Roy 0 Reputation points
2026-01-17T18:54:54.5666667+00:00

Hi,

I have a piece of code to generate PDF using puppeteer with Node 22. It works fine with Consumption plan when used with remote build and directing it to right cache directory.

But the same piece does not work when deployed to flex consumption plan. The following error occurs:

Failed to launch the browser process: Code: 127 stderr: /home/site/wwwroot/.cache/puppeteer/chrome/linux-143.0.7499.192/chrome-linux64/chrome: error while loading shared libraries: libglib-2.0.so.0: cannot open shared object file: No such file or directory

Any help on how to resolve this?

-ADR

Azure Functions
Azure Functions

An Azure service that provides an event-driven serverless compute platform.

Locked Question. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

2 answers

Sort by: Oldest
  1. AI answer

    2026-01-17T18:55:03.8933333+00:00

    The error you are encountering when using Puppeteer in the Azure Functions Flex Consumption plan is likely due to missing shared libraries that Puppeteer relies on to launch the browser. The specific error message indicates that the library libglib-2.0.so.0 is not found, which is a common issue when running Puppeteer in environments that do not have all the necessary dependencies installed.

    To resolve this issue, you can try the following steps:

    1. Include Required Libraries: Ensure that your Azure Function includes all the necessary libraries for Puppeteer. You may need to create a custom Docker image that includes these libraries or use a pre-built image that has them.
    2. Use a Custom Handler: If you are using a custom handler, ensure that it is configured correctly to include all dependencies.
    3. Check Azure Functions Documentation: Review the Azure Functions documentation for any specific requirements or recommendations for using Puppeteer in the Flex Consumption plan. This may include information on how to package your function app with the necessary binaries and libraries.
    4. Test Locally: If possible, test your function locally in an environment that closely matches the Azure Flex Consumption plan to identify any missing dependencies before deploying.

    If these steps do not resolve the issue, consider reaching out to Azure support or checking community forums for additional guidance specific to Puppeteer and Azure Functions Flex Consumption.

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

  2. Pravallika KV 18,795 Reputation points Microsoft External Staff Moderator
    2026-01-19T01:34:35.6366667+00:00

    Hi @Anupam Dutta Roy ,

    Thanks for the confirmation.

    You're correct. With Flex Consumption, it’s currently not possible to deploy or install additional native OS libraries such as libglib-2.0.so.0 the way it was sometimes feasible with the classic Consumption plan. Flex runs on a more restricted base image and doesn’t support customizing the underlying OS layer.

    Because Puppeteer/Chromium depends on native system libraries, this becomes a platform limitation rather than a configuration issue. Falling back to Azure Container Apps or App Service / Premium Functions is the recommended and supported approach when those dependencies are required.

    Failed to launch the browser process: Code: 127 stderr: /home/site/wwwroot/.cache/puppeteer/chrome/linux-143.0.7499.192/chrome-linux64/chrome: error while loading shared libraries: libglib-2.0.so.0: cannot open shared object file: No such file or directory

    The error message indicates that the libglib-2.0.so.0 library is missing.

    Unlike the Consumption plan, the Flex Consumption plan may have different library support and restrictions.

    Here's what you can try to resolve the issue:

    1. Check Library Dependencies: Make sure that your code or Puppeteer configuration isn't relying on libraries that aren't available in the Flex Consumption environment. Since the error mentions a missing library, you may need to include it as part of your deployment package or find a compatible version that doesn't require that library.
    2. Use Docker: If you have the option, consider deploying your function inside a Docker container. This way, you have full control over the environment, and you can install any dependencies your application needs. This approach works well for running Puppeteer since you can install all required libraries and dependencies.
    3. Explore Alternative Plans: If possible, evaluate whether another hosting option (like the Premium plan) might suit your needs better if the Flex Consumption plan's library limitations are too restrictive for your requirements.
    4. Check Azure Documentation: You might want to review specific guidelines from Microsoft on Flex Consumption Plan Hosting to see if there are any additional constraints related to library support.
    5. Function App Logs: Check your function app's logs on Azure to gather more insights into any other potential issues that might be feeding into this error.

    Hope this helps!


    If the resolution was helpful, kindly take a moment to click on 210246-screenshot-2021-12-10-121802.pngand click on Yes for was this answer helpful. And, if you have any further query do let us know.

    Was this answer helpful?

    0 comments No comments