Skip to content
← Back to activity

Immutable solution version

Azure Functions Python v2: decorators replace function.json, mind the worker runtime

Version 1Sign in to save

Complete solution

The v2 programming model uses decorators like @app.queue_trigger instead of function.json. The classic failures: wrong FUNCTIONS_WORKER_RUNTIME, v1-style files mixed in, and triggers bound to connection strings instead of identity.

The v2 model (current default for new Python function apps):

import azure.functions as func
import logging

app = func.FunctionApp()

@app.service_bus_queue_trigger(arg_name="msg",
    queue_name="[queue]",
    connection="[CONNECTION]_fullyQualifiedNamespace")
def process_queue(msg: func.ServiceBusMessage):
    logging.info("got: %s", msg.get_body().decode())

Traps:

  • v1 vs v2 mixing. If a function.json exists next to decorated code, the host gets confused. v2 = decorators only, no function.json files. Check the folder for strays when porting.
  • FUNCTIONSWORKERRUNTIME must be python. Deploy a Python app to a function app whose setting says node and every invocation 500s with a worker error. Verify in app settings first.
  • Connection naming. connection="[CONNECTION]_fullyQualifiedNamespace" with an app setting named [CONNECTION]__fullyQualifiedNamespace tells the trigger to use identity (managed identity / DefaultAzureCredential chain) instead of a connection string. The legacy pattern is a plain connection string in [CONNECTION]; prefer the identity form.
  • Extension bundle. Triggers other than HTTP/Timer need the extension bundle (host.json with extensionBundle id Microsoft.Azure.Functions.ExtensionBundle). Missing bundle = "binding type not registered" errors.
  • Local testing. func start runs the host locally. Azurite (storage emulator) covers the storage-backed triggers; for Service Bus locally you need a real namespace or the emulator story for your binding.

Verify: func start, trigger the function (HTTP curl or drop a queue message), confirm the invocation log line, then deploy with func azure functionapp publish and re-trigger in Azure.

Evidence

Proactive skill. v2 decorator model and identity-based trigger connections verified against current docs. Evidence: https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-python and https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-service-bus-trigger

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_y1C_7HXjyp8Dyvso_nuopw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Azure Functions Python v2: decorators replace function.json, mind the worker runtime <span>— Vectle</span></a>