Python CosmosDB trigger failing to show up in Azure Functions GUI

AdamHumiecki-2359 0 Reputation points
2025-02-06T02:26:43.9933333+00:00

Hello,

We are currently working on trying to deploy a python cosmosDB-triggered function to an azure function app (v2), and while we have had successful deployments of the relevant files to the resource, it simply does not appear in the GUI (the files are present on the host however)

Generally this means there is an issue with modules/package dependencies, but I have verified in our appInsight traces/logs that there are no 'moduleNotFound' errors, and have verified that the proper dependencies are present in site/wwwroot/.python_packages/lib/site_packages directory. We are using an azure devops pipeline for the initial build (essentially pip install -r requirements.txt), which wraps up the relevant packages and function .py files into a zip archive, which is deployed onto the host using zipDeploy

Traces after deployment give no errors, simply info logs that state 0 functions found 0 functions loaded
At this point I am not sure what is wrong. I have: verified the environment settings on the azure function app resource mirror local.settings.json values (and our developers are able to run this function locally), and I believe our function_app.py has a properly formatted trigger:

@app.cosmos_db_trigger(
    arg_name="azcosmosdb",
    container_name="staging",
    database_name="Product_Catalog",
    connection="COSMOSDB_CONNSTRING",
    create_lease_container_if_not_exists=True,
    lease_container_name="leases",
    start_from_beginning=True,
)
@app.function_name(name="CosmosToCtFn")

Does the community have any suggestions on what I can try next? We have:

  • Tried remote deployment using azure core functions with no success
  • Destroyed and rebuilt the azure function resources
  • Extracted the zip package and ensured it can run locally (although a developer needed to reinstall packages to do so, but used the same pip install -r requirements.txt --upgrade --target=.python_packages/lib/site-packages/ command as featured in our pipeline)
  • verified that the build agent that runs the install command and the azure function app are on the same version of python (3.9)

Azure functions does not seem to give any clear logs or information on why exactly it wouldnt recognize the function, and we are confused on how it works locally but not on the function resource when the dependencies are present - are there any suggestions on what might be missing?

Thank you!

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,397 questions
Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,749 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Shireesha Eeraboina 1,550 Reputation points Microsoft Vendor
    2025-02-07T04:36:28.1833333+00:00

    Hi @AdamHumiecki-2359,

    Welcome to the Microsoft Q&A Platform! Thank you for asking your question here.

    It seems you're encountering a common problem with Azure Functions where the function isn't being recognized, despite a successful deployment. Here are some troubleshooting suggestions to help you resolve this issue:

    • Make sure that the function name and decorators are applied correctly. The @app.function_name(name="CosmosToCtFn") should be properly formatted, and the function itself should be defined accurately.
    • Since you indicated that the files are present on the host, verify that the structure of the deployment package is correct. The function should be located in the appropriate directory structure within site/wwwroot.
    • Although you mentioned that there are no ModuleNotFound errors, consider enabling more detailed logging in Azure Functions. This can often uncover issues that may not be immediately obvious.
    • Verify that the environment variables, particularly COSMOSDB_CONNSTRING, are correctly configured in the Azure portal and align with those in your local settings.
    • Make sure that the Azure Function App is set to use the correct runtime version that corresponds with your local development environment. Occasionally, rebuilding the function app and redeploying can help resolve issues. Ensure that there are no cached versions causing conflicts.
    • If relevant, consider using a storage emulator such as Azurite for local testing, as it can assist in identifying issues related to storage connections.

    For your reference, please review the following documentations for further clarification.

    Azure Functions triggers and bindings concepts

    Azure Functions Python developer guide

    By following these steps, you should be able to identify and resolve the issue with your Cosmos DB-triggered function not appearing in the Azure Function App GUI.

    If you find the answer helpful, kindly click "Accept Answer" and upvote it. If you have any further questions or concerns, please feel free to reach out to us. We are happy to assist you.

    0 comments No comments

Your answer

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