Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable Synchronous IO in Azure Function

I am building a HTTPTriggered Azure Function, targeting netcoreapp3.0, that is running a GraphQL .NET server. GraphQL .NET requires that AllowSynchronousIO is set to true, but I can't figure out how to do that for a Azure Function. I have tried implementing my own Startup class that extends FunctionsStartup and added the below code in the Configure method with no luck.

builder.Services
    .AddOptions<KestrelServerOptions>()
    .Configure<IConfiguration>((settings, configuration) =>
    {
        settings.AllowSynchronousIO = true;
        configuration.Bind(settings);
    });

The error message I get is:

An unhandled host error has occurred.

Microsoft.AspNetCore.Server.Kestrel.Core: Synchronous operations are disallowed. Call WriteAsync or set AllowSynchronousIO to true instead.

Any help would be greatly appreciated!

like image 903
Ganhammar Avatar asked Dec 17 '19 18:12

Ganhammar


1 Answers

Setting the environment variable FUNCTIONS_V2_COMPATIBILITY_MODE to true seems to solve the issue, see https://github.com/Azure/azure-functions-host/pull/5286.

like image 106
Ganhammar Avatar answered Nov 14 '22 22:11

Ganhammar