-
Notifications
You must be signed in to change notification settings - Fork 207
Description
Expected Behavior
When a Azure Function is triggered by an Event Hub event, you get a azure.functions.EventHubEvent Class. This class has the attribute "metadata" - "read-only trigger metadata in a Python dictionary". From it I should be able to access the system and custom properties of the event, e.g. the Correlation ID.
Actual Behavior
When I print the content of the metadata, the "correlation-id" field is empty. I got only the Custom Property "somecustomproperty".
Steps to Reproduce
Create a simple Azure Function triggered by Event Hub as documented here. In the function body log the whole metadata like this:
logging.info(f"Whole event metadata: {myhub.metadata}")
You can use the Data Explorer from the Event Hub page in the Azure Portal to send a sample event. Just make sure that under "System Properties" the Correlation ID is not empty.
Relevant code being tried
import logging
import azure.functions as func
app = func.FunctionApp()
@app.function_name(name="EventHubTrigger1")
@app.event_hub_message_trigger(arg_name="myhub",
event_hub_name="<EVENT_HUB_NAME>",
connection="<CONNECTION_SETTING>")
def test_function(myhub: func.EventHubEvent):
logging.info(f"Whole event metadata: {myhub.metadata}")
Relevant log output
{
"SequenceNumber": 486099,
"PartitionContext": {
"IsCheckpointingAfterInvocation": True,
"FullyQualifiedNamespace": "***",
"EventHubName": "***",
"ConsumerGroup": "local_func_debug",
"PartitionId": "0"
},
"SystemProperties": {
"message-id": {},
"user-id": {
"Length": 0,
"IsEmpty": True
},
**"correlation-id": {},**
"content-type": "text/plain",
"x-opt-sequence-number-epoch": -1,
"x-opt-sequence-number": 486099,
"x-opt-offset": 1958513386000,
"x-opt-enqueued-time": "2025-05-13T15:14:40.71+00:00",
"SequenceNumber": 486099,
"Offset": 1958513386000,
"PartitionKey": None,
"EnqueuedTimeUtc": "2025-05-13T15:14:40.71"
},
"TriggerPartitionContext": {
"IsCheckpointingAfterInvocation": True,
"FullyQualifiedNamespace": "***",
"EventHubName": "***",
"ConsumerGroup": "local_func_debug",
"PartitionId": "0"
},
"EnqueuedTimeUtc": "2025-05-13T15:14:40.71",
"Properties": {
"somecustomproperty": "somevalue"
},
"Offset": 1958513386000
}
requirements.txt file
azure-functions>=1.20.0,<2.0.0
Where are you facing this problem?
Local - Core Tools
Additional Information
Using Python 3.11/3.12 in a Linux Function App with Runtime version ~4.