我有一个 OrchestrationTrigger 函数,可以通过 http 请求调用另一个服务。
[FunctionName("MyFunc")]
public async Task RunOrchestrator(
[OrchestrationTrigger] IDurableOrchestrationContext context,
ILogger logger)
{
var req = new DurableHttpRequest(HttpMethod.Post, _uri, headers, jsonBody);
var res = await context.CallHttpAsync(req);
// Do something
}
Run Code Online (Sandbox Code Playgroud)
但出现以下错误:
检测到多线程执行。如果 Orchestrator 函数代码等待的任务不是由 DurableOrchestrationContext 方法创建的,则可能会发生这种情况。更多详细信息可以在这篇文章中找到 :https://learn.microsoft.com/en-us/azure/azure-functions/durable-functions-checkpointing-and-replay#orchestrator-code-constraints。
那里的官方文档建议使用 context.CallHttpAsync- 正是我所做的。