An Azure service that provides an event-driven serverless compute platform.
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:
requestsis not installed in the function runtime environment. - Solution: Ensure
requestsis inrequirements.txtand 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=trueand 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-packagesin CI, include.python_packagesin artifact.
- Option A (server-side build): set app setting
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
virtualenvbut 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_PACKAGEset to 1 or a package URL butSCM_DO_BUILD_DURING_DEPLOYMENTnot 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']"