0

I have a simple Azure python function with the v2 programming model with decorator approach and I needed to redeploy it. It always worked in the first place, I debugged it locally and it works just fine

[2023-07-22T20:00:20.933Z] Mapped function route 'api/req' [all] to 'az2am'
[2023-07-22T20:00:20.933Z]
[2023-07-22T20:00:20.933Z]   "RoutePrefix": "api"
[2023-07-22T20:00:20.933Z] }
[2023-07-22T20:00:20.942Z] Host initialized (109ms)
[2023-07-22T20:00:20.944Z] Host started (120ms)
[2023-07-22T20:00:20.944Z] Job host started
[2023-07-22T20:00:20.949Z] Subscribed to diagnostic source 'Microsoft.Azure.WebJobs.Logging.ApplicationInsights.ApplicationInsightsLoggerProvider'

Functions:

        az2am:  http://localhost:7071/api/req

Now if I deploy it (with oryx remote build) the deployment went just fine I can see all files within the function app but the function itself doesn't show up under the function tab. I see in Application Insights the following error messages:

Initializing function HTTP routes No HTTP routes mapped No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).

I did research and already found out that you have to set the app setting AzureWebJobsFeatureFlags=EnableWorkerIndexing

I'm a bit clueless as I have similar functions running with the same v2 settings. I already tried a function with app plan and consumption plan, it makes no difference.

My function code

    app = func.FunctionApp()
    @app.function_name(name='az2am')
    @app.route(route='req')
    def main(req: func.HttpRequest) -> func.HttpResponse:
      useless_stuff()
      return func.HttpResponse(status_code=204)

host.json (tried with version 3.*,4.0.0 too)

    {
      "version": "2.0",
      "logging": {
        "applicationInsights": {
          "samplingSettings": {
            "isEnabled": true,
            "excludedTypes": "Request"
          }
        }
      },
      "extensionBundle": {
        "id": "Microsoft.Azure.Functions.ExtensionBundle",
        "version": "[4.*, 5.0.0)"
      }
    }

Anybody has an idea what the problem could be?

0

2 Answers 2

1

If you didn't set the setting "AzureWebJobsFeatureFlags": "EnableWorkerIndexing" in local.setting.json file, then you will receive this kind of error,

enter image description here

We have to set that setting for the python v2 model Azure Function.

local.setting.json:

{
  "IsEncrypted": false,
  "Values": {
    "FUNCTIONS_WORKER_RUNTIME": "python",
    "AzureWebJobsStorage": "<your_storage_connec_string>",
    "AzureWebJobsFeatureFlags": "EnableWorkerIndexing"
  }
}

Output:

enter image description here

Refer to this SO # 74686213

Sign up to request clarification or add additional context in comments.

Comments

1

When encountering this error on older versions of Azure Functions, it's important to check the folder structure of your project. Ensure that your function is located in a folder that corresponds to the name of the endpoint you are trying to implement. Next, you should have an __init__.py file that contains all your code, as well as a function.json file that describes the configuration of your function.

Ensure that the function name in __init__.py is main. This is the function that Azure Functions runtime will look for as the entry point for your function.

init.py

function.json

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.