Azure Durable Functions - OrchestrationTrigger 连续执行第一个等待 Activity

Azure Durable Functions - OrchestrationTrigger continuously executing 1st awaited Activity

我创建了一个 Azure Durable Function following the structure of the Fan-out / Fan-In 示例,(使用推荐的 VS 2017 开发,而不是 Azure 门户方法)

我遇到的是从 OrchestrationTrigger 方法调用的第一个 Azure 函数被一遍又一遍地调用,并且永远不会继续到下一个语句。现在,虽然我已经阅读了事件溯源、检查点和 Orchestrator 重播文档以及 Orchestrator Code Constraints,但我仍然有点困惑,因为由于重播,本地调试非常棘手。

[FunctionName("ExportLogs")]
public static async Task ExportLogs([OrchestrationTrigger] DurableOrchestrationContext context)
{
    SinceDate since = context.GetInput<SinceDate>();
    var sinceDate = DateTime.Parse(since.since);

    var conversationInfos = await context.CallActivityAsync<IEnumerable<ConversationInfo>>("GetConversations", sinceDate);

    // !! I never get to this statement
    var tasks = new List<Task<CallInfo>>(conversationInfos.Count());
    foreach (var ci in conversationInfos)
    {
        Task<CallInfo> task = context.CallActivityAsync<CallInfo>("ProcessCall", ci);
        task.Start();
        var notused = task.ContinueWith(t => context.CallActivityAsync("PersistCallInStorage", t.Result));
        tasks.Add(task);
    }
    await Task.WhenAll(tasks);

    // Now fan-in and persist all results.
    var callInfos = tasks.Select(t => t.Result);
    var connectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
    var repo = new DwRepository(connectionString);
    repo.AddCallInfos(callInfos);
}

调用的第一个 activity 是:

[FunctionName("GetConversations")]
public static IEnumerable<ConversationInfo> GetConversations([ActivityTrigger] DateTime sinceDate, TraceWriter log)
{
    var exportService = ConstuctExportService();
    var conversations = exportService.GetAllConversations(sinceDate);
    return conversations;
}

现在,exportService.GetAllConversations(sinceDate); 正在调用一个 SDK,该 SDK 通过 REST 从云服务中获取一些调用信息。它确实需要循环并获取页面中的数据。所以发生的事情是,即使我正在等待呼叫,它也会被一遍又一遍地调用,并且永远不会继续。

这是函数运行时输出的输出 window:

[10/23/2017 7:25:43 PM] Function started (Id=8e62e6bd-34a9-49b7-a814-3a0e9e5f9f8e)
[10/23/2017 7:25:43 PM] Executing 'ExportRscCallLogs' (Reason='', Id=8e62e6bd-34a9-49b7-a814-3a0e9e5f9f8e)
[10/23/2017 7:25:43 PM] b350f681b17b4ac8a772fff8fdca3aad: Function 'ExportRscCallLogs (Orchestrator)', version '' started. IsReplay: False. Input: (22 bytes). State: Started. HubName: DurableFunctionsHub. AppName: . SlotName: . ExtensionVersion: 1.0.0.0.
[10/23/2017 7:25:44 PM] b350f681b17b4ac8a772fff8fdca3aad: Function 'GetConversations (Activity)', version '' scheduled. Reason: ExportRscCallLogs. IsReplay: False. State: Scheduled. HubName: DurableFunctionsHub. AppName: . SlotName: . ExtensionVersion: 1.0.0.0.
[10/23/2017 7:25:44 PM] Function completed (Success, Id=8e62e6bd-34a9-49b7-a814-3a0e9e5f9f8e, Duration=114ms)
[10/23/2017 7:25:44 PM] Executed 'ExportRscCallLogs' (Succeeded, Id=8e62e6bd-34a9-49b7-a814-3a0e9e5f9f8e)
[10/23/2017 7:25:44 PM] b350f681b17b4ac8a772fff8fdca3aad: Function 'ExportRscCallLogs (Orchestrator)', version '' awaited. IsReplay: False. State: Awaited. HubName: DurableFunctionsHub. AppName: . SlotName: . ExtensionVersion: 1.0.0.0.
[10/23/2017 7:25:44 PM] b350f681b17b4ac8a772fff8fdca3aad: Function 'GetConversations (Activity)', version '' started. IsReplay: False. Input: (23 bytes). State: Started. HubName: DurableFunctionsHub. AppName: . SlotName: . ExtensionVersion: 1.0.0.0.
[10/23/2017 7:25:44 PM] Function started (Id=3c33ff3b-5fe5-4e6b-a7d4-ac6c3e146633)
[10/23/2017 7:25:44 PM] Executing 'GetConversations' (Reason='', Id=3c33ff3b-5fe5-4e6b-a7d4-ac6c3e146633)
[10/23/2017 7:25:47 PM] Function completed (Success, Id=3c33ff3b-5fe5-4e6b-a7d4-ac6c3e146633, Duration=2824ms)
[10/23/2017 7:25:47 PM] Executed 'GetConversations' (Succeeded, Id=3c33ff3b-5fe5-4e6b-a7d4-ac6c3e146633)
[10/23/2017 7:25:47 PM] b350f681b17b4ac8a772fff8fdca3aad: Function 'GetConversations (Activity)', version '' completed. ContinuedAsNew: False. IsReplay: False. Output: (435216 bytes). State: Completed. HubName: DurableFunctionsHub. AppName: . SlotName: . ExtensionVersion: 1.0.0.0.
[10/23/2017 7:25:54 PM] b350f681b17b4ac8a772fff8fdca3aad: Function 'GetConversations (Activity)', version '' started. IsReplay: False. Input: (23 bytes). State: Started. HubName: DurableFunctionsHub. AppName: . SlotName: . ExtensionVersion: 1.0.0.0.
[10/23/2017 7:25:54 PM] Function started (Id=d89b2fa4-f4d7-43e5-95f1-5cf436ebc85e)
[10/23/2017 7:25:54 PM] Executing 'GetConversations' (Reason='', Id=d89b2fa4-f4d7-43e5-95f1-5cf436ebc85e)
[10/23/2017 7:25:56 PM] Function completed (Success, Id=d89b2fa4-f4d7-43e5-95f1-5cf436ebc85e, Duration=1397ms)
[10/23/2017 7:25:56 PM] Executed 'GetConversations' (Succeeded, Id=d89b2fa4-f4d7-43e5-95f1-5cf436ebc85e)
[10/23/2017 7:25:56 PM] b350f681b17b4ac8a772fff8fdca3aad: Function 'GetConversations (Activity)', version '' completed. ContinuedAsNew: False. IsReplay: False. Output: (435216 bytes). State: Completed. HubName: DurableFunctionsHub. AppName: . SlotName: . ExtensionVersion: 1.0.0.0.
[10/23/2017 7:26:05 PM] b350f681b17b4ac8a772fff8fdca3aad: Function 'GetConversations (Activity)', version '' started. IsReplay: False. Input: (23 bytes). State: Started. HubName: DurableFunctionsHub. AppName: . SlotName: . ExtensionVersion: 1.0.0.0.
[10/23/2017 7:26:05 PM] Function started (Id=fb240d9c-90f0-4e4d-86db-b3d2c175e0eb)
[10/23/2017 7:26:05 PM] Executing 'GetConversations' (Reason='', Id=fb240d9c-90f0-4e4d-86db-b3d2c175e0eb)
[10/23/2017 7:26:06 PM] Function completed (Success, Id=fb240d9c-90f0-4e4d-86db-b3d2c175e0eb, Duration=1177ms)
[10/23/2017 7:26:06 PM] Executed 'GetConversations' (Succeeded, Id=fb240d9c-90f0-4e4d-86db-b3d2c175e0eb)
[10/23/2017 7:26:06 PM] b350f681b17b4ac8a772fff8fdca3aad: Function 'GetConversations (Activity)', version '' completed. ContinuedAsNew: False. IsReplay: False. Output: (435216 bytes). State: Completed. HubName: DurableFunctionsHub. AppName: . SlotName: . ExtensionVersion: 1.0.0.0.

如您所见,日志显示它一遍又一遍地显示Executing 'GetConversations',甚至每次都报告它已成功完成。 IsReplay 参数为 False - 所以我不确定发生了什么?

如有任何帮助,我们将不胜感激。

感谢 Chris Gillum 努力找出发布的问题 issue。他发现我的首字母activity是

returning back a relatively large amount of data (482564 bytes, or 471 KB). Return values get serialized into queue messages, and Azure storage queues only support 64 KB messages. I suspect the runtime is not handling this gracefully and is resulting in it running continuously.