在 Azure Function 中启用同步 IO [英] Enable Synchronous IO in Azure Function
问题描述
我正在构建一个 HTTPTriggered Azure 函数,目标是运行 GraphQL .NET 服务器的 netcoreapp3.0.GraphQL .NET 要求将 AllowSynchronousIO
设置为 true
,但我不知道如何为 Azure 函数做到这一点.我已经尝试实现我自己的 Startup
类,它扩展了 FunctionsStartup
并在 Configure
方法中添加了以下代码,但没有成功.
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);
});
我得到的错误信息是:
发生了未处理的主机错误.
An unhandled host error has occurred.
Microsoft.AspNetCore.Server.Kestrel.Core:同步操作是不允许.调用 WriteAsync 或将 AllowSynchronousIO 设置为 true.
Microsoft.AspNetCore.Server.Kestrel.Core: Synchronous operations are disallowed. Call WriteAsync or set AllowSynchronousIO to true instead.
任何帮助将不胜感激!
推荐答案
将环境变量 FUNCTIONS_V2_COMPATIBILITY_MODE
设置为 true
似乎可以解决问题,请参阅 https://github.com/Azure/azure-functions-host/pull/5286.
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.
这篇关于在 Azure Function 中启用同步 IO的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!