When redeploying Azure Function Apps python site_packages aren't available

Neta Peleg 0 Reputation points

Hi I have a Function App which I am deploying using terraform.

I Use a zip deployment.

In my first deployment everything works fine.

Once I upload a new zip file to the WEBSITE_RUN_FROM_PACKAGE path I start getting Exception: ModuleNotFoundError: No module named 'azure.identity'


I am able to see updates to the function's code, e.g add a function, or add a return a different message from a function.

The site_packages directory is identical between the re-deployments.

I tried to restart / start & stop the function app from the azure console but nothing helps.

I Also tried to change the path in WEBSITE_RUN_FROM_PACKAGE and upload to a new location on each deployment but still get the ModuleNotFoundError exception.

Would appreciate any help with this issue

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,610 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. VasimTamboli 4,775 Reputation points

    If you are redeploying an Azure Function App using a zip deployment and encountering a "ModuleNotFoundError" for the 'azure.identity' module, there are a few possible causes and solutions to consider:

    Verify Python Dependencies: Make sure that the 'azure.identity' module is included in your zip package and its dependencies are correctly specified. Double-check your requirements.txt or any other file that lists the Python dependencies for your Function App.

    Python Version and Environment: Ensure that the Python version used in your Azure Function App matches the one you are developing with locally. It's possible that the 'azure.identity' module requires a specific Python version or an environment with specific packages installed. Confirm that you have the correct Python version and environment settings in your Function App.

    Virtual Environment: If you are using a virtual environment for your Python dependencies, ensure that it is correctly configured and activated during the deployment process. Make sure that the virtual environment is created, activated, and the dependencies are installed before deploying the zip package.

    Check Function App Settings: Review the settings in your Function App to ensure that the WEBSITE_RUN_FROM_PACKAGE configuration is correctly pointing to the location of your zip package. Verify that the path is set correctly and that the zip file is successfully uploaded to that location.

    Clean Deployment: In some cases, residual files or conflicts from previous deployments can cause issues. Try performing a clean deployment by removing the existing Function App and deploying it again from scratch. This ensures a clean environment for the new deployment.

    Logging and Diagnostics: Enable logging and diagnostics in your Function App to get more detailed information about the deployment process and any errors that occur. Check the logs for any specific error messages related to the 'azure.identity' module or other missing dependencies.

    If the issue persists after trying these solutions, you may need to provide more specific details about your deployment process, dependencies, and any error messages encountered during the deployment. This will help in further diagnosing and resolving the problem.