在 Azure 持久函数中设置 MaxOrchestrationActions

Setting MaxOrchestrationActions in an Azure Durable Function

我们正在使用 Durable Orchestrator Function,它需要对 Activity 函数进行数百万次调用。我们在 100,000 次调用后看到以下异常:

Maximum amount of orchestration actions 100,000 has been reached. This value can be configured in host.json file as MaxOrchestrationActions.

但是,我找不到如何设置这个值。

host.json schema here中没有指定。

我已经拉动了 Azure Function Durable Extension 开发分支的负责人并跟踪了源代码。看起来这个 可以 设置为 DurableTaskOptions.MaxOrchestrationActions,但它必须在传递到 DurableOrchestrationContext class.

之前设置

我们猜测 host.json 中的 属性 可能是

{
   "extensions": {
      ... other settings omitted for brevity ...
      "durableTask": {
         "MaxOrchestrationActions": xxxx
      }
   }
}

但是运气不好。

有人指导如何设置 MaxOrchestrationActions 吗?

更新 我的问题是我使用的是 Microsoft.Azure.WebJobs.Extensions.DurableTask 框架的旧版本。更新到 2.1.1 后,它按预期工作。

我已向 Microsoft 文档团队报告缺少 maxOrchestrationActions 文档,他们正在更新文档。

没错,默认值为 100k,您应该可以使用 host.json 进行更改。

我注意到两件事:您没有提供版本号,也没有使用驼峰式大小写:

{
   "version": "2.0",
   "extensions": {
      "durableTask": {
         "maxOrchestrationActions": xxxx
      }
   }
}

更多信息:

https://docs.microsoft.com/en-us/dotnet/api/microsoft.azure.webjobs.extensions.durabletask.durabletaskoptions?view=azure-dotnet

https://github.com/Azure/azure-functions-durable-extension/pull/982/commits/fd63d9436ef7fe4748c3a6aff95f9ac8596ab587

对我来说,推荐的答案没有用。这可能是因为我有依赖注入。所以我设法通过像这样注入 DurableTaskOptions 来实现这一点:

.AddSingleton<IOptions<DurableTaskOptions>>(new OptionsWrapper<DurableTaskOptions>(
                    new DurableTaskOptions
                        {MaxOrchestrationActions = 1500000}))