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?

1 Answers1

0

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

Dasari Kamali
  • 811
  • 2
  • 2
  • 6