如何检查运行状态和停止 Durable 功能

Pan*_*wat 6 azure azure-durable-functions

我想按需处理数百万条记录,大约需要 2-3 个小时来处理。我想要无服务器,这就是为什么尝试持久功能(第一次)。我想检查一下,我可以运行持久函数多长时间,所以我创建了 3 个函数

  1. 用于启动 Orchestrator 功能的 Http 功能
  2. 编排器功能 在此处输入图片说明
  3. 活动功能

在此处输入图片说明

我的 DurableFunction 正在运行并在 Application Insights 中发出过去 5 天的日志,根据我的代码,它需要 15 天才能完成。

我想知道如何手动停止 Orchestrator 功能?

我可以在 ApplicationInsights 请求表中看到数千个单次执行条目,有没有办法检查后端运行了多少个 DurableFunction?以及单次执行需要多少时间?

我可以在“DurableFunctionHubInstance”表中看到一些有关协调器功能的信息,但正如 MS 建议的那样,不要依赖表。

Mar*_*arc 11

由于 Durable Functions 会执行大量检查点并重播编排,因此正常的日志记录可能并不总是很有洞察力。

获取状态

有多种方法可以查询业务流程的状态。其中之一是通过George Chen 提到的Azure Functions Core 工具

另一种查询状态的方法是直接使用 Durable Functions 的 HTTP API:

GET <rooturl>/runtime/webhooks/durableTask/instances?
    taskHub={taskHub}
    &connection={connectionName}
    &code={systemKey}
    &createdTimeFrom={timestamp}
    &createdTimeTo={timestamp}
    &runtimeStatus={runtimeStatus1,runtimeStatus2,...}
    &showInput=[true|false]
    &top={integer}
Run Code Online (Sandbox Code Playgroud)

文档中的更多信息。

HTTP API 还具有清除业务流程的方法。无论是单一一个由ID由日期时间/状态倍数

DELETE <rooturl>/runtime/webhooks/durabletask/instances/{instanceId}
    ?taskHub={taskHub}
    &connection={connection}
    &code={systemKey}
Run Code Online (Sandbox Code Playgroud)

最后,您还可以使用DurableOrchestrationClientC# 中的API管理您的实例。这是 GitHub 上的示例:HttpGetStatusForMany.cs

如果您想了解有关如何在 C# 中使用它的更多信息,我已经撰写记录了有关使用DurableOrchestrationClientAPI 的内容。

自定义状态

小补充:可以向编排添加自定义状态对象,以便您可以添加有关编排进度的丰富信息。

获取持续时间

当您查询编排实例的状态时,您会得到一个DurableOrchestrationStatus对象。这包含两个属性:

  • 创建时间
  • 上次更新时间

我猜你可以减去这些并得到它所花费时间的合理指示。