在 Azure Function 中启用同步 IO

Gan*_*mar 7 .net-core azure-functions graphql-dotnet

我正在构建一个 HTTPTriggered Azure 函数,目标是运行 GraphQL .NET 服务器的 netcoreapp3.0。GraphQL .NET 要求将AllowSynchronousIO其设置为true,但我不知道如何为 Azure 函数执行此操作。我尝试实现我自己的Startup类,该类扩展FunctionsStartup并在Configure方法中添加了以下代码,但没有成功。

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

我得到的错误信息是:

发生了未处理的主机错误。

Microsoft.AspNetCore.Server.Kestrel.Core:不允许同步操作。调用 WriteAsync 或将 AllowSynchronousIO 设置为 true。

任何帮助将不胜感激!

Gan*_*mar 13

将环境变量设置FUNCTIONS_V2_COMPATIBILITY_MODEtrue似乎可以解决问题,请参阅https://github.com/Azure/azure-functions-host/pull/5286