c# - Azure Durable Functions - OrchestrationTrigger 连续执行第一个等待的事件

标签 c# azure azure-functions

我创建了一个Azure Durable Function遵循 Fan-out / Fan-In 的结构例如,(使用推荐的 VS 2017 开发,而不是 Azure Portal 方法)

我遇到的情况是,从 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);
}

调用的第一个事件是:

[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 从云服务获取一些调用信息。它确实需要循环并获取页面中的数据。所以发生的情况是,尽管我正在等待调用,但它被一遍又一遍地调用,并且永远不会继续。

以下是函数运行时输出窗口的输出:

[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.

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

任何帮助将不胜感激。

最佳答案

感谢 Chris Gillum 努力找出发布的问题 issue 。他发现我最初的事件是

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.

关于c# - Azure Durable Functions - OrchestrationTrigger 连续执行第一个等待的事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46897136/

相关文章:

Azure 逻辑应用-条件操作错误 'The provided types object and object are not compatible'

azure - 外部 api 管理服务无法解析 Azure 函数服务名称

azure - 使用 Azure 流分析 HoppingWindow 函数进行事件处理(每天 1700 万个事件) - 24 小时窗口,1 分钟跳跃

c# - 在unity 2D c#中如何旋转像几何破折号这样的对象?

c# - 使用 Dispatcher.Invoke 从 WPF 中的不同线程关闭窗口

c# - 来自函数的可变数量的结果

c# - 关于Unity中的OnRenderImage函数

.net - 如何查找 .NET 命名空间的程序集名称,例如 Microsoft.WindowsAzure.ServiceRuntime

azure - 增加 Azure 数据磁盘大小

Azure函数: Service Bus input binding (not trigger)