Open surgupta-msft opened 11 months ago
I also encounter issues with this while running .NET 8 isolated. After some testing I found:
Case 1: Endless loop until timeout
var host = new HostBuilder()
.ConfigureFunctionsWebApplication()
.ConfigureFunctionsWorkerDefaults()
Case 2: 200 OK, but without response body
var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults()
.ConfigureFunctionsWebApplication()
Using either of them solo fixes it and therefor I'm not sure if they are supposed to be used together.. but it's a scenario we currently have.
Also, I have the same behavior.
Question, is it possible to benefits of the ASP.NET Core integration and also to be able to inject custom middleware? For example builder.UseMiddleware<CustomMiddleware>()
. is there another alternative?
Yes, it is possible, as it turns out, you just need to:
.ConfigureFunctionsWebApplication(workerApplication => { workerApplication.UseWhen< CorsHttpHeaderMiddleware >(context => { return context.FunctionDefinition.InputBindings.Values .First(a => a.Type.EndsWith("Trigger")).Type == "httpTrigger"; }); })
Because ConfigureFunctionsWebApplication
allready calls ConfigureFunctionsWorkerDefaults
I also encounter issues with this while running .NET 8 isolated. After some testing I found:
Case 1: Endless loop until timeout
var host = new HostBuilder() .ConfigureFunctionsWebApplication() .ConfigureFunctionsWorkerDefaults()
Case 2: 200 OK, but without response body
var host = new HostBuilder() .ConfigureFunctionsWorkerDefaults() .ConfigureFunctionsWebApplication()
Using either of them solo fixes it and therefor I'm not sure if they are supposed to be used together.. but it's a scenario we currently have.
I think you are only supposed to use either one of them, not both. Have a look the docs here
Hi all - yes, confirming that we generally expect only one of these to be used, and I'd default to using ConfigureFunctionsWebApplication
to get the performance benefits that come with ASP.NET Core integration, unless you are targeting .NET Framework 4.8.
Any news on this issue?? I realized that if I have a http trigger and a servicebus trigger in the same function app it get conflicts by just using .ConfigureFunctionsWebApplication()
, only the http trigger works and for the servicebus trigger I get an exception of: An exception was thrown by the invocation. [2024-09-03T12:44:27.345Z] Exception: System.InvalidOperationException: Unable to resolve service for type 'Microsoft.Azure.ServiceBus.Grpc.Settlement+SettlementClient' while attempting to activate 'Microsoft.Azure.Functions.Worker.ServiceBusMessageActionsConverter'
If I try to use both together the servicebus trigger works but for the http trigger I get same result of ktriple comment:
I also encounter issues with this while running .NET 8 isolated. After some testing I found:
Case 1: Endless loop until timeout
var host = new HostBuilder() .ConfigureFunctionsWebApplication() .ConfigureFunctionsWorkerDefaults()
Case 2: 200 OK, but without response body
var host = new HostBuilder() .ConfigureFunctionsWorkerDefaults() .ConfigureFunctionsWebApplication()
Using either of them solo fixes it and therefor I'm not sure if they are supposed to be used together.. but it's a scenario we currently have.
Trigger not working as expected when
ConfigureFunctionsWorkerDefaults()
is registered in Asp.Net Core Integration app. Also, evaluate if we need analyzer for this scenario.Repro steps and behavior seen
ConfigureFunctionsWorkerDefaults()
in Asp.NetCore app. Sample for referenceExpected behavior
Trigger should work successfully emitting the expected output log: Welcome to Azure Functions!
Additional notes from offline discussion
ConfigureFunctionsWebApplication()
is a superset ofConfigureFunctionsWorkerDefaults()
.ConfigureFunctionsWorkerDefaults()
is registered with an AspNet app.