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
Invoking a non-HTTP triggered function locally using the Azure Functions Core Tools Admin API (cardinality: one) #764
Comments
Hi again, I believe I should share some more background where we are aiming at. Originally, I've misplaced that within Azure/azure-functions-host#6603 (comment) and Azure/azure-functions-host#6603 (comment). We are currently looking into running full integration tests with pytest through a host instance provided by azure-functions-core-tools. Our idea was to spin up a function/host instance from a pytest fixture, submit a single or more messages to it by e.g. invoking
and then check the outcome of what has been done when processing the message(s) (e.g. writing to a database). Now, after sublimating myself more thoroughly into the code base, I found azure_functions_worker.testutils.start_webhost as well as tests.endtoend.test_eventhub_functions.test_eventhub_trigger, which probably perfectly reflect our goal. Kudos to @1st1, @Hazhzeng, @elprans, @vrdmr, @ankitkumarr and @maiqbal11. From reading that code, I learned that there is probably no way to invoke an EventHub Trigger function directly. Instead, the idea seems to be to use a HTTP Trigger in order to indirectly submit an event to EventHub, right?
With kind regards, |
Hi again, despite learning that the
It is all revolving around the aspect how to phrase the request body and whether it would work using a JSON body at all. With kind regards, |
@amotl If I understood your problem correctly, I think that I found the "magic" format that needs to be submitted through the POST call. This is how I was able to use the Admin API with Event Hub trigger function: curl --request POST 'http://localhost:7071/admin/functions/MyFunctionName' --header 'Content-Type: application/json' --data-raw '{"input": "{\"SystemProperties\":{},\"myteststuff\":{\"testid\":\"810d9efd-458c-49f2-a9c0-822c897a02e3\",\"testtimestamp\":\"2020-10-28 23:24:16.315294\"},\"testdata\":\"Ping from Az CLI IoT Extension #1\"}"}' First thing, the JSON in the POST request needs to follow this pattern: If the
|
Dear Tadas,
Ah, that is awesome! Thank you so much for applying your wizardry to the problem we have been facing here. I just wanted to leave you a quick appreciation and will follow up on this next week. With kind regards, |
Dear Tadas, we translated the
Thanks again! Now, we are actually aiming at submitting a list of events, reflected by using a binding attribute With kind regards, |
Dear @stefanushinardi, @anirudhgarg, @anthonychu and @Hazhzeng, may I humbly suggest to add the outcome of this research by @kepalas to the aforementioned documentation at The gist is:
With kind regards, |
Also facing issues trying to figure out what to sent as |
Is your question related to a specific version? If so, please specify:
Found Python version 3.8.5 (python3).
Azure Functions Core Tools (3.0.2931 Commit hash: d552c6741a37422684f0efab41d541ebad2b2bd2)
Function Runtime Version: 3.0.14492.0
What binding does your question apply to, if any? (e.g. Blob Trigger, Event Hub Binding, etc)
Event Hub Trigger Binding (cardinality: one)
Question
Hi there,
we are trying to follow the documentation about how to pass test data to a non-HTTP triggered function to invoke a Python function locally when running within the Azure Functions Core Tools host.
We are using the EventHub Trigger binding, so the function signature looks like that:
Now, we are trying to figure out how exactly to formulate what to put into
<trigger_input>
in our scenario.When submitting an obviously wrong request like
the host says
When naively sending real JSON like
{"input": [{"device-id": "1"}]}
, the host responds with<Response [400]>
(Bad Request).After these observations, we started digging through the source code of the host and the python function worker in order to figure out how to build an appropriate payload reflecting the "real" thing but quickly got lost.
While it is obvious that there will be more efforts required to send a complex object instead of a simple scalar string as outlined within the example
we are now wondering if that would be possible at all. Maybe you can help us out?
Thank you very much in advance and with kind regards,
Andreas.
The text was updated successfully, but these errors were encountered: