问题
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!
回答1:
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.
来源:https://stackoverflow.com/questions/59379971/enable-synchronous-io-in-azure-function