corvus-dotnet / Corvus.Testing

Extensions and utilities for testing, primarily focused on SpecFlow. Sponsored by endjin.
Apache License 2.0
14 stars 10 forks source link

How do you host multiple functions in the same project, and call them? #239

Closed imaji closed 2 years ago

imaji commented 3 years ago

I've got an Azure Function project with two functions in. One's an HTTP Trigger, the other a Timer Trigger.

Using the Azure Function specflow bits, I can point at the project, and the functions start up fine. I can navigate to the local address, and get the "You functions are running" page.

However, when I try calling the HTTP Function using it's defined route, I get 404 back. If I then remove the Timer function, make the exact same call to the same URL as before, it now resolves function, and enters the Run method.

So basically, how do I host multiple functions in a single project? Should I be able to just make the call to the expected route using the HttpClient and expect it to work?

Thanks!

jongeorge1 commented 3 years ago

Hi, yes, I'd expect it to just work.

To test this, I added a timer triggered function to the demo project, set to execute every 5 seconds and include the last execution time in the message returned by the GET endpoint. I also tweaked the specs to take account of, and test for this, and it all looks to be working fine. You can see the code here - I'd be interested to know if the specs all pass for you.

https://github.com/corvus-dotnet/Corvus.Testing/tree/feature/239-timer-trigger-issue

Also worth checking what version of azure-functions-core-tools you have installed globally. For info, I'm currently on 3.0.3442.

If the specs pass, but you still see the problem when using your own functions, are you able to share your code (or a stripped down version) so I can see the issue in action?

imaji commented 3 years ago

Ok cool, I'll try modding the demo functions and see if I can replicate my problem.

I realised I'd missed off an important detail, I'm actually using the recently released .net 5 Azure Functions.

imaji commented 3 years ago

I'm on 3.0.3442 as well :)

jongeorge1 commented 3 years ago

Ah, yes, that is an important detail! We haven't done any testing against the .NET 5 version of Azure Functions. Please let us know how you get on. Thanks!

imaji commented 3 years ago

Ok, this repo (unmodified) doesn't pass running the tests locally :(

The function call is returning "<!DOCTYPE html>Your Azure Function App is up and running.