HTTP Functions that use Microsoft.Azure.Functions.Worker.Http
m-flak opened this issue · 2 comments
I have an HTTP-triggered Azure function with the following signature, using the Microsoft.Azure.Functions.Worker.Http.*
classes for the request and response data.
[Function(...)]
public async Task<HttpResponseData> Run([HttpTrigger(...)] HttpRequestData req, FunctionContext context)
{
/*...*/
}
I was unable to get UnitTestEx to work with this setup and had to do my unit testing with Moq and mock classes for those request/response classes.
My functions project uses the isolated worker model, and I followed the example setup the best I could.
In the end, I was unable to use this library because it could not handle HttpRequestData/HttpResponseData.
I am still new to using Azure Functions, so if I can switch these over to what UnitTestEx supports, I'm unaware. 😃
Hi,
This is a challenge with the isolated worker model where Microsoft introduced new types, versus the more widely used HttpRequest
and HttpResponse
. Thankfully, Microsoft has now (recently) added support for these types; see this article for guidance on usage.
Generally, my guidance is to use HttpRequest
and HttpResponse
as there are many other libraries, etc. out there that support, and means development is largely consistent with an ASP.NET Core implementation.
Cheers...