pythonazureazure-functions

Azure Function v2 Python deployed functions are not showing


Locally the functions debug just fine, if I deploy via vscode to my azure function I get No HTTP Triggers found and the devops pipeline does not deploy triggers either.

I have "AzureWebJobsFeatureFlags": "EnableWorkerIndexing" set locally and as a function app setting.

Code is appropriately decorated

@app.route(route="functionname", auth_level=func.AuthLevel.FUNCTION)
def functioname(req: func.HttpRequest) -> func.HttpResponse:

Deployments succeed both ways but no functions show

Azure Pipeline shows correct files: enter image description here

Azure function app files show function_app.py at the root folder

test function

app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS)    
@app.function_name("personas")
    @app.route(route="character-managment/personas")
    def personas(req: func.HttpRequest) -> func.HttpResponse:
        logging.info('Python HTTP trigger function processed a request.')
    return func.HttpResponse("ok", status_code=200)

Folder structure

enter image description here

Works locally

enter image description here


Solution

  • I tried to reproduce the same in my environment. I could see the deployed function in Azure function app.

    Local:

    enter image description here

    {
      "IsEncrypted": false,
      "Values": {
        "FUNCTIONS_WORKER_RUNTIME": "python",
        "AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
        "AzureWebJobsStorage": "<storage_connection_string>"
      }
    }
    
    py -m venv .venv
    .\.venv\Scripts\activate
    

    enter image description here

    enter image description here

    enter image description here

    enter image description here

    Portal:

    enter image description here

    enter image description here


    I could also deploy the function with custom packages to Azure Function App.

    requirements.txt:

    azure-functions
    numpy
    pandas
    

    Code(function_app.py):

    import azure.functions as func
    import logging
    import numpy as np
    import pandas as pd
    app = func.FunctionApp()
    
    
    @app.route(route="HttpTrigger", auth_level=func.AuthLevel.ANONYMOUS)
    def HttpTrigger(req: func.HttpRequest) -> func.HttpResponse:
        logging.info('Python HTTP trigger function processed a request.')
    
        arr = np.array([1, 2, 3])
        df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]})
    
        name = req.params.get('name')
        if not name:
            try:
                req_body = req.get_json()
            except ValueError:
                pass
            else:
                name = req_body.get('name')
    
        if name:
            return func.HttpResponse(f"Hello, {name}. This HTTP triggered function executed successfully with {arr} and {df}.")
        else:
            return func.HttpResponse(
                 "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.",
                 status_code=200
            )
    

    Local:

    enter image description here

    enter image description here enter image description here

    Portal:

    enter image description here

    enter image description here

    References:

    Create a Python function from the command line

    You can also refer GitHub ticket raised on the same issue.