Share via

Azure Function is not working

Amrutha M 20 Reputation points
2025-09-15T06:25:37.1933333+00:00

User's image

We are facing error while creating the function app, its not working as required and mentioned in the azure documents

Azure Functions
Azure Functions

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


1 answer

Sort by: Most helpful
  1. Rakesh Mishra 9,695 Reputation points Microsoft External Staff Moderator
    2025-09-18T02:35:57.5+00:00

    Hi Amrutha M, please find below possible causes and solutions for it. Please let me know if still facing issue and need any further assistance on this.

    Issue 1 - ModuleNotFoundError: No module named 'requests'
    • Problem: Function fails at import time with No module named 'requests'.
    • Cause: requests is not installed in the function runtime environment.
    • Solution: Ensure requests is in requirements.txt and that dependencies are installed during deployment.
    Issue 2 - requirements.txt present but ignored by deployment (zip/run-from-package)
    • Problem: requirements.txt exists but the runtime still can't import the package.
    • Cause: Zip-deploy / Run-from-Package was used without enabling server-side build; platform did not run pip install.
    • Solution: Enable build or install deps in pipeline:
      • Option A (server-side build): set app setting SCM_DO_BUILD_DURING_DEPLOYMENT=true and redeploy (or use func publish --build remote).
            az functionapp config appsettings set -g <RG> -n <APP> --settings SCM_DO_BUILD_DURING_DEPLOYMENT=true
        
      • Option B (CI build): run pip install -r requirements.txt -t .python_packages/lib/site-packages in CI, include .python_packages in artifact.
    Issue 3 - Dependencies installed only in local venv / not packaged into artifact
    • Problem: Dev machine has requests; deployed artifact lacks it.
    • Cause: Packages installed in local virtualenv but CI/build didn’t package site-packages.
    • Solution: In CI (Azure DevOps / GitHub Actions), add a step to install and include dependencies:
        pip install -r requirements.txt -t .python_packages/lib/site-packages
        zip -r artifact.zip .  # include .python_packages
        # deploy artifact.zip (or use Azure WebAppsPublish/ZipDeploy task)
      
    Issue 4 - App setting WEBSITE_RUN_FROM_PACKAGE prevents server build
    • Problem: App runs from package and ignores platform build steps.
    • Cause: WEBSITE_RUN_FROM_PACKAGE set to 1 or a package URL but SCM_DO_BUILD_DURING_DEPLOYMENT not enabled.
    • Solution: Either enable server build or change deployment to include built dependencies. Check setting:
        az functionapp config appsettings list -g <RG> -n <APP_NAME> --query "[?name=='WEBSITE_RUN_FROM_PACKAGE' || name=='SCM_DO_BUILD_DURING_DEPLOYMENT']"
      

    Was this answer helpful?

    0 comments No comments

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.