An Azure service that provides an event-driven serverless compute platform.
Hi Maya,
Welcome to Microsoft Q&A Azure
This issue usually happens when Python packages aren’t properly installed during deployment, causing the ModuleNotFoundError: No module named 'docx'. Here’s how to troubleshoot and fix it:
Check the build process
- Review deployment logs:
Go to
https://<your-function-name>.scm.azurewebsites.net/api/logs/docker/zipdeploy.build.log
or Deployment Center -> Logs to confirm ifpip install -r requirements.txtfailed.
Confirm app settings:
In Configuration -> Application settings, make sure:
SCM_DO_BUILD_DURING_DEPLOYMENT=true
ENABLE_ORYX_BUILD=true
Validate your requirements.txt:
Example:
python-docx==1.1.0
azure-functions
Avoid relative paths or local dependencies.
Ensure correct structure:
The function_app.py (with @app.route) and requirements.txt should be in the project root.
Recommended actions
Deploy manually for detailed logs:
func azure functionapp publish <APP_NAME> --python
Check installed packages via SSH/Kudu:
pip list
cat requirements.txt
Consider using GitHub Actions or Azure Pipelines for clean remote builds.
References:
- Debug Python Azure Functions deployments https://learn.microsoft.com/azure/azure-functions/functions-reference-python
- Azure Functions app settings (SCM_DO_BUILD_DURING_DEPLOYMENT e outras variáveis) https://learn.microsoft.com/azure/azure-functions/functions-app-settings#scm_do_build_during_deployment
- Best practices for Python Azure Functions development and deployment https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-python?tabs=get-started%2Casgi%2Capplication-level&pivots=python-mode-decorators