Enable Synchronous IO in Azure Function

狂风中的少年 提交于 2020-05-15 09:09:13

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!