Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to receive events batch in Eventhub triggered function #411

Closed
joal42 opened this issue May 8, 2019 · 8 comments · Fixed by #527
Closed

How to receive events batch in Eventhub triggered function #411

joal42 opened this issue May 8, 2019 · 8 comments · Fixed by #527
Assignees
Labels
func-stack: Python P0 [P0] items : Ship blocking

Comments

@joal42
Copy link

joal42 commented May 8, 2019

Investigative information

I have a eventhub triggered function in python and want to receive events in batch.

In function.json set cardinality to many
"cardinality": "many",
What should the parameter in main function to pass a list of events?

This example can only get one event data:
def main(event: func.EventHubEvent):

@pragnagopa
Copy link
Member

@asavaritayal - This needs to be documented. Receiving a batch of eventhub events is the recommended approach.
@elprans - Can you share sample code for receiving an array or list of eventHubEvent?

@asavaritayal asavaritayal modified the milestones: Triaged, Functions Sprint 50 May 10, 2019
@anirudhgarg anirudhgarg modified the milestones: Functions Sprint 50, Functions Sprint 51 May 30, 2019
@asavaritayal
Copy link
Contributor

@1st1 @elprans once you provide a sample, I can go update the documentation.

@maiqbal11
Copy link
Contributor

maiqbal11 commented Jun 13, 2019

While working on a different EventHub issues, came across this issue: Azure/azure-functions-eventhubs-extension#118 (unresolved as of now). Looks like setting cardinality to many has the potential to error out if valid json is not provided. Wanted to make a note of this because I ran into this with our default EventHub template in core tools. If we are going to be recommending cardinality : many as a way to get batched events, we should at least ensure that the default experience works.

@joal42
Copy link
Author

joal42 commented Jun 13, 2019

@maiqbal11 Thanks for linking the webjobs issue. I set to many and use the input as bytes. And then, I convert bytes to array of string. It looks working fine. It would be better if you can share some default usage example.

@joal42
Copy link
Author

joal42 commented Jun 21, 2019

@maiqbal11 I found that I lose eventhub meta data, like offset if I use batch model. Could you also help with how to get eventhub meta date in batch processing?

@pragnagopa
Copy link
Member

For batch processing, trigger data and metadata is received as an array via RPC. Please see java sample code here: https://github.com/Azure/azure-functions-java-worker/blob/dev/endtoendtests/src/main/java/com/microsoft/azure/functions/endtoend/EventHubTriggerTests.java#L27
Note: SystemPropertiesArray is populated by the java worker.

@elprans / @maiqbal11 - Does python worker expose an array of metadata?

@joal42
Copy link
Author

joal42 commented Jun 24, 2019

@pragnagopa Thanks for your information. I checked the similar test code path https://github.com/Azure/azure-functions-python-worker/blob/dev/tests/test_eventhub_functions.py
I didn't find the similar metadata array populated.
@elprans @maiqbal11 It would be nice if you can help with it.

@maiqbal11
Copy link
Contributor

The SystemPropertiesArray isn't currently being populated by the Python worker. Will need to make a change that allows it to handle this case.

@maiqbal11 maiqbal11 added the P0 [P0] items : Ship blocking label Jul 29, 2019
kaibocai pushed a commit that referenced this issue Aug 19, 2022
It includes fix of the CI. I've done two things. 1. Fix timeout issue on CosmosDB. 2. Make HttpClient as static. This part is not the root cause of the CI fail, however, I keep it as better practice than instantiate eachtime.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
func-stack: Python P0 [P0] items : Ship blocking
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants