Azure Function (Python) and EventHub triggers and sending

goldiiman 1 Reputation point
2021-01-03T16:18:29.697+00:00

I am using Azure Function (using Python) and Event Hub (triggers), the examples uses:

binding [type] : "eventHubTrigger", and [name]: "events". Python function generated (using func new)

def main(events: List[func.EventHubEvent]) -> str:

I have 2 issues

1)
A list of messages in, but I can only send 1 string?? Can I return a list of strings / messages which would be converted to Event bus messages on the outbound binding

2)
If I bind the input to [name] : event (not s), I get a single message in but the sending examples use

await producer.create_batch()

which passes in a list regardless of the binding. Can I create a single message (and not a batch of 1)

Seems a mismatch in the azure.eventhub Python SDK forcing batches but the event hub triggering not supporting batches in AND out

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,571 questions
Azure Event Hubs
Azure Event Hubs
An Azure real-time data ingestion service.
591 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Pramod Valavala 20,606 Reputation points Microsoft Employee
    2021-01-04T14:29:02.053+00:00
    1. For multiple output messages, you could return a list instead of returning a single string. While the docs don't cover a sample for EventHub, the same as the one for Queue Storage
    2. There is a cardinality property that can be set in the function.json file for the function that returns multiple messages instead of one. Refer this as a sample.

    Please feel free to open feedback items on the docs to include samples for the same.

    0 comments No comments