Azure / Azure/azure-functions-host

Flex Consumption: Service Bus queue trigger settles messages but never invokes the Python function (no errors logged anywhere)

Open
#11,879 0 comments 0 reactions 0 assignees View on GitHub
Needs: Triage (Functions)
Dominant language
C#
Stars
2k
Forks
482
Avg merge
2d 10h
Merged PRs (30d)
36

Description

### Investigation environment
- **Function App**: `consumer-function`, Poland Central, Flex Consumption plan
- **Runtime**: Python 3.12, functions v4, `azure-functions` (latest)
- **Trigger**: `service_bus_queue_trigger` (Python v2 programming model)

### Summary
On a Flex Consumption Python Function App, a Service Bus-triggered function intermittently — and eventually consistently — stops being invoked when a message arrives, even though the message is dequeued/settled at the Service Bus transport layer. No exception, warning, or trace of any kind is logged anywhere (Application Insights `traces`/`requests`/`exceptions`, host logs, Service Bus dead-letter queue) to explain what happened to the invocation.

### Repro
```python
import logging
import azure.functions as func

app = func.FunctionApp()

@app.function_name(name="consumer-function")
@app.service_bus_queue_trigger(
arg_name="msg",
queue_name="docs-queue",
connection="ServiceBusConnection",
)
def consumer(msg: func.ServiceBusMessage) -> None:
body = msg.get_body().decode("utf-8")
logging.info("Received Service Bus message: %s", body)
```
`host.json` and `requirements.txt` are minimal/default (extension bundle `[4.*, 5.0.0)`, `azure-functions` only).

1. Deploy the above to a Flex Consumption Function App.
2. Send a message to the queue.
3. Observe: the message disappears from the queue (`activeMessageCount` and `deadLetterMessageCount` both go to 0), and Service Bus namespace metrics (`IncomingMessages`/`OutgoingMessages`) confirm exactly one message was received and settled.
4. Observe: **zero** entries appear in Application Insights `requests`, `traces`, or `exceptions` for the invocation. No "Executing"/"Executed" host trace, no custom log line, nothing.

### What was ruled out
- **Competing consumer**: namespace `ActiveConnections` metric stayed flat at 1 for the entire test window.
- **Code/config mismatch**: pulled the deployed `function_app.py` via Kudu VFS and confirmed it matched the source; `admin/functions` host endpoint confirmed the correct `queueName`/`connection` binding.
- **Queue-specific corruption**: created a brand-new queue and repointed the function at it — identical failure.
- **App-level corrupted state**: fully deleted and recreated the Function App from scratch on Flex Consumption — identical failure.
- **Cold-start-only**: burst-sent 5 messages in immediate succession — all 5 vanished from the queue, zero invocations recorded.
- **Always-ready instances**: set `scale config always-ready` to 1 pre-warmed instance for the function. Host restarted 5 times within 32 seconds after applying the setting, then the next test message still produced zero invocations.

### Control test
Recreated the identical function (same code, same Service Bus namespace/queue) on a classic **App Service (Basic B1, Linux)** plan instead of Flex Consumption. It worked correctly and consistently on the first attempt:
```
Executing 'Functions.consumer_function' (Reason='(null)', Id=...)
Trigger Details: MessageId: ..., DeliveryCount: 1, EnqueuedTimeUtc: ...
Python ServiceBus Queue trigger processed a message: {...}
Executed 'Functions.consumer_function' (Succeeded, Id=..., Duration=279ms)
```

### Expected behavior
Every message settled by the Service Bus trigger extension should correspond to exactly one logged function invocation (success or failure) — or, failing that, some error surfaced in host logs / Application Insights / DLQ explaining why it didn't run.

### Actual behavior
On Flex Consumption specifically, messages are silently settled without any corresponding invocation record, with no error surfaced through any observability channel. The only successful invocations observed happened in a short window immediately after a fresh deployment while the instance was already warm from the deploy process itself; every other test resulted in silent message loss.

### Additional notes
- Region: Poland Central (`polandcentral`)
- Instance memory: 512 MB, max instances: 100 (defaults)
- `functionAppConfig.runtime.version`: 3.12 (also reproduced independently on a separately-created app defaulting to 3.14)
- Happy to provide subscription/resource IDs, correlation IDs, or Application Insights export privately if a maintainer wants to dig into backend logs.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the trigger with the shown function_app.py, minimal host.json, and requirements.txt on Flex Consumption, then compare its behavior with the working App Service deployment. Check the admin/functions endpoint and Application Insights requests, traces, and exceptions while messages are settled. Done means every settled message has an invocation record or an observable error explaining the outcome.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, python
Domain
backend, cloud
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.