Share via

Unable to use linux packages In Flexi Function app

Mohamed Farees M 0 Reputation points
2026-06-04T14:31:08.1033333+00:00

We are planning to migrate from Consumption Function app to flexi function app. In Consumption function have we have pdf creation function which use linux library files. But in flexi even though I see GitHub workflow success, manual deployment success I can see my function app is failing with 400 error . Not sure how to migrate to Flexi

Packages used: libcairo2 libfontconfig1 libgdk-pixbuf2.0-0 libglib2.0-0 libharfbuzz0b libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 shared-mime-info

Azure Functions
Azure Functions

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

0 comments No comments

2 answers

Sort by: Most helpful
  1. Rakesh Mishra 9,585 Reputation points Microsoft External Staff Moderator
    2026-06-04T16:46:29.76+00:00

    Hello Mohamed,

    Thank you for reaching out to the Microsoft Q&A community.

    The issue you are encountering is due to the fact that your PDF generation code relies on specific OS-level Linux libraries (such as cairo, pango, etc.), which are not included in the default environment for the Flex Consumption plan.

    Unfortunately, you cannot install these system libraries or use a custom container on the Flex Consumption plan. As per the official Microsoft documentation, Flex Consumption operates in a sandboxed environment without root access and only supports code deployments.

    Quoting the Deployment technologies in Azure Functions documentation:

    "One deploy is the only deployment technology available for function apps running in a Flex Consumption plan... When you create a Flex Consumption app, you must specify a deployment storage (blob) container... The end result is a ready-to-run .zip package."

    Additionally, the Functions infrastructure as code documentation explicitly confirms that the Flex Consumption plan is restricted to "Code-only", whereas plans like Premium and Dedicated support both "Code | Container".

    Resolution:

    To resolve the missing dependencies, you will need to migrate your function to a hosting plan that supports Custom Containers. This gives you full root control over the underlying OS to install necessary Linux packages. You can choose one of the following alternatives:

    1. Azure Functions Premium Plan or Dedicated (App Service) Plan
    2. Azure Container Apps (ACA)

    Here is how you can resolve it using an Azure Functions Premium Plan:

    1. Create a Custom Dockerfile: Build a custom container based on the official Azure Functions base image and install your OS-level dependencies.
         FROM mcr.microsoft.com/azure-functions/python:4-python3.11
         # Install necessary Linux packages for PDF generation
         RUN apt-get update && \
             apt-get install -y libcairo2 libpango-1.0-0 libpangocairo-1.0-0 libgdk-pixbuf2.0-0 shared-mime-info && \
             apt-get clean && rm -rf /var/lib/apt/lists/*
         COPY . /home/site/wwwroot
      
    2. Push the Image: Build and push this Docker image to a registry such as Azure Container Registry (ACR).
    3. Deploy to Premium Plan: Create a new Azure Function App, choose Container as the Publish option, select the Premium pricing plan, and configure it to pull your custom image.

    Please let me know if you need any further clarification on migrating your plan.

    Note: This response is drafted with the help of AI system.

    Was this answer helpful?


  2. AI answer

    2026-06-04T14:31:54.89+00:00

    Flex Consumption apps run on a different hosting model than the classic Linux Consumption plan and don’t support in-place migration. A new Flex Consumption app must be created and then the code and dependencies redeployed.

    For a Linux Consumption app that uses native Linux packages (like libcairo2, libpango, etc.), the supported migration path is:

    1. Create a new Flex Consumption app
      • Use az functionapp flex-migration start to create a new Flex Consumption app from the existing Consumption app configuration:
             az functionapp flex-migration start \
                 --source-name <SOURCE_APP_NAME> \
                 --source-resource-group <SOURCE_RESOURCE_GROUP> \
                 --name <NEW_APP_NAME> \
                 --resource-group <RESOURCE_GROUP>
        
      • This copies most configuration (app settings, identities, storage mounts, CORS, custom domains, access restrictions) from the source app to the new Flex app.
    2. Move the code as a package deployment
      • First, obtain the deployment package from the existing app:
        • If WEBSITE_RUN_FROM_PACKAGE is a URL, download the .zip from that URL.
        • Otherwise, locate the package in the storage account (container scm_releases, file scm-latest-<APP_NAME>.zip) and download it.
      • Deploy that same package to the new Flex app using:
             az functionapp deployment source config-zip \
                 --resource-group <RESOURCE_GROUP> \
                 --name <NEW_APP_NAME> \
                 --src <PACKAGE_PATH>
        
    3. Verify runtime and bindings compatibility
      • Flex Consumption supports only specific runtime versions. If the assessment or migration output shows Invalid version {0} for runtime {1} for function apps on the Flex Consumption plan. Supported versions for runtime {1} are {2}., the app’s runtime or language version must be upgraded before migration.
      • After deployment, if the app returns 400s or fails to start, use the troubleshooting guidance:
        • In the new app, open Diagnose and solve problemsAvailability and Performance and check Function App Down or Reporting Errors.
        • In Application InsightsFailures and Logs, query traces and requests for errors to see if missing dependencies or binding issues are reported.
    4. Handle native Linux packages explicitly
      • Flex Consumption runs on a managed Linux image; only the packages included in that image are available by default. If the app depends on specific native libraries (like libcairo2, libpango, etc.), ensure the Flex runtime and deployment model being used support those dependencies.
      • If the app fails with 400 due to startup errors, Application Insights logs (especially traces with severityLevel == 3) will show whether the script host fails to load because of missing native libraries or incompatible runtime.
    5. Roll back if needed
      • If the Flex app cannot be made to start correctly, keep the original Consumption app running and roll back traffic while troubleshooting. The migration guidance explicitly recommends rollback to the original app if production issues occur.

    Because Flex Consumption does not support in-place plan migration, the working pattern is: assess compatibility → create a new Flex app with az functionapp flex-migration start → redeploy the package → verify logs and fix any runtime/dependency issues.


    References:

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

    Was this answer helpful?

Your answer

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