我是否需要使用 Azure Durable Functions 的 CreateTimer 方法手动保存状态?

Do I need to manually preserve state with Azure Durable Functions' CreateTimer method?

我第一次在持久编排中使用计时器。我发现 CreateTimer 有一个 overload that acceptes an object of type T,它在触发后返回,代表我想要保留的状态。

请问这是什么状态?据我了解,在任何情况下,编排功能都会保留状态。因此,由于在 after CreateTimer<T> 行恢复代码之前重新执行了编排器,因此不需要手动保留状态。

我错了吗?有人可以对此进行更多说明吗?

非常感谢任何帮助,谢谢。

你说得对,一切都会被重播,实际上不需要为任何使用持久函数扩展的人传递任何类型的状态。我认为存在重载的主要原因是因为持久任务库,其中 OrchestratorContext class 有这样一个方法,由 DurableOrchestrationContext 在内部使用。这个库并不意味着只能与 azure 持久函数一起使用,而是可以用于任何长时间运行的编排工作。来自自述文件 github.

The Durable Task Framework (DTFx) is a library that allows users to write long running persistent workflows (referred to as orchestrations) in C# using simple async/await coding constructs. It is used heavily within various teams at Microsoft to reliably orchestrate long running provisioning, monitoring, and management operations. The orchestrations scale out linearly by simply adding more worker machines. This framework is also used to power the serverless Durable Functions extension of Azure Functions.

从他们 github 的样本来看,它似乎主要用于调试和测试目的,以保持某种状态,例如重试次数。