首页 > 解决方案 > Orchestrator 函数代码等待不是由 DurableOrchestrationContext 方法创建的任务

问题描述

我在 Orchestrator 函数中有以下代码:

                var sourceGroups = await context.CallActivityAsync<AzureADGroup[]>(nameof(SourceGroupsReaderFunction), new SourceGroupsReaderRequest { SyncJob = syncJob, RunId = runId });
            
                if (sourceGroups.Length == 0)
                {
                    await _log.LogMessageAsync(new LogMessage
                    {
                        RunId = runId,
                        Message =
                        $"None of the source groups in {syncJob.Query} were valid guids. Marking job as errored."
                    });
                    await _calculator.SendEmailAsync(syncJob, runId, SyncDisabledNoValidGroupIds, new[] { syncJob.Query });
                }

在运行它时,我看到以下错误:

Function 'OrchestratorFunction (Orchestrator)' failed with an error. Reason: System.InvalidOperationException: Multithreaded execution was detected. This can happen if the orchestrator function code awaits on a task that was not created by a DurableOrchestrationContext method. More details can be found in this article https://docs.microsoft.com/en-us/azure/azure-functions/durable-functions-checkpointing-and-replay#orchestrator-code-constraints.

我错过了什么?

标签: azure-durable-functions

解决方案


推荐阅读