For few months now I deploy .NET 8 azure function project with no issues.
Today it errored on any deployment attempt and I notice the error in program.cs that .ConfigureFunctionsWorkerDefaults()
should be .ConfigureFunctionsWebApplication()
see here.
after changing, all my responses started erroring with:
System.InvalidOperationException: Synchronous operations are disallowed. Call WriteAsync or set AllowSynchronousIO to true instead.at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpResponseStream.Write
I found some ways to set AllowSynchronousIO to true but they relate to Core 3 or 6. Nothing about .NET 8
I know I could change to await response.WriteAsJsonAsync(
but then I will have to change all the consumers of the APIs and it is a lot to change.
How can I add AllowSynchronousIO to true in my program.cs
var host = new HostBuilder()
.ConfigureFunctionsWebApplication()
.ConfigureServices(services =>
{
services.AddApplicationInsightsTelemetryWorkerService();
services.ConfigureFunctionsApplicationInsights();
})
.Build();
host.Run();
Any help? Thank you