-
Notifications
You must be signed in to change notification settings - Fork 103
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
[Bug] Testing Batched Event Hub Trigger #1524
[Bug] Testing Batched Event Hub Trigger #1524
Comments
Thanks for informing will check and update you |
Hi @JonasEichhorn, thanks for reporting this issue. HTTP-Trigger Issue After some investigation, this is what I found when the cardinality is set to many: Input data: In the python SDK: we load in the data, calculate list length, and then create that many EventHubEvents. Since here the length is one, only one EventHubEvent is created. In summary, when the cardinality is set to many, the entire input body is wrapped in a list. This is done through the extension, not the worker. I can transfer this issue / create one over this with them. Typing Issue: Emulator Issue: |
Thanks for looking into it! I haven't found the open emulator issue, when I was writing this. Thanks! Sorry, for answering so late. I've been on vacation.
I would expect
Thank you very much, for looking into this. It would be great, if you could transfer the issue or create a new issue for me. Thanks! |
@hallvictoria Can you give me the link to the typing-PR? |
You can track the EventHub cardinality issue here: Azure/azure-sdk-for-net#45337. Please feel free to add more information if needed. I will link the typing PR to this issue once ready. Thanks again for your patience! |
Thanks you very much, @hallvictoria! |
Hi @JonasEichhorn, thanks for your patience. One follow-up question: how are you sending data to trigger the function? I tried using an HTTP trigger POST request with an EventHub output binding, and I didn't get the nested list. Input Data:
I was able to repro the nested list issue, but only when using the Generate Data feature in the portal. Using an HTTP trigger (or any trigger, HTTP is not required) and output binding worked as expected. |
The problem arouse with event hub triggers. We start a function app locally with docker for testing. Everything works fine, if you read events from an event hub. However, it does not work, if you try to test the event hub triggered function without an event hub, but use a POST request to manually trigger non-HTTP-triggered functions (like so https://learn.microsoft.com/en-us/azure/azure-functions/functions-manually-run-non-http?tabs=azure-portal). Just for clarification, is this related to Azure/azure-sdk-for-net#45337 or am I missing the scope of this issue and Azure/azure-sdk-for-net#45337? |
Ah, I see now. Thanks for clarifying. This way is for manual testing, which is different from interacting with prod resources. Complex data isn't supported with manual testing. According to the documentation, the specific <TRIGGER_INPUT> you supply depends on the type of trigger, but it can only be a string, numeric, or boolean value. When For manual testing, which is more limited compared to prod scenarios, I would suggest instead sending data in in one of the supported types. It was related -- I was trying to determine under what conditions the nested list input data occurred. Since you have confirmed that interacting with prod resources works as expected and the issue occurs when doing manual testing, this looks to be a known limitation of manual testing and not necessarily an issue on the worker or sdk side. |
Thank you for looking into it. Are there any plans to make the event hub trigger testable with |
For manually running non-HTTP functions, I'm not aware of any plans or timeline for supporting complex data types. We do support unit testing for functions. It allows you to mock the function input and call the function directly, so this could provide an alternative way for you to test the functions. I agree that the documentation isn't clear, so I'll see if we can get this information highlighted. |
Thanks! |
Expected Behavior
Actual Behavior
{'input': {'some': 'awesome', 'event': 'body'}}
gives an EventHubEvent with the body[{'some': 'awesome', 'event': 'body'}]
.{'input': [{'some': 'awesome', 'event': 'body'}, {'some': 'other', 'event': 'body'}]}
gives a nested list[[{'some': 'awesome', 'event': 'body'}, {'some': 'other', 'event': 'body'}]]
I had to write a check to convert single events into a list in order to test my function locally and had to extract all the functionality in a seperate function which is called from my function so I can test it with batches. This solution is not pretty, but fine.
Unfortunately, the type hinting breaks loading the azure function. I dont know why, but proper typing
def batch_triggered(events: func.EventHubEvent | List[func.EventHubEvent]):
prohibits the function from being loaded. It is found, but not loaded. Doingdef batch_triggered(events: List[func.EventHubEvent]):
ordef batch_triggered(events: func.EventHubEvent):
is fine, though.I also tried to use the new event hub emulator instead of triggering the function via HTTP for my tests, but the event hub always refuses the connection. I don't know, if this is an issue of the emulator or the worker. I'm raising this issue here, because the emulator does work with the current version of the python SDK.
Steps to Reproduce
HTTP-Trigger Issue
Typing Issue
def batch_triggered(events: func.EventHubEvent | List[func.EventHubEvent]):
Event Hub Emulator Issue
connection
parameter.docker compose up
. Function startup will fail, becasue event hub emulator refuses the connectionRelevant code being tried
No response
Relevant log output
No response
requirements.txt file
No response
Where are you facing this problem?
Local - Core Tools
Function app name
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered: