Activity 函数需要当前时间 - Azure Functions
Activity Function needs current Time - Azure Functions
所以我有一个看起来像这样的持久函数:
[FunctionName("functionName")]
public async Task functionName([OrchestrationTrigger] IDurableOrchestrationContext context)
{
// some code here
string name = "name";
await context.CallActivityAsync("activityFunction", name);
}
[FunctionName("activityFunction")]
public async Task ActivityFunction([ActivityTrigger] IDurableActivityContext name)
{
// perform an operation here
// need to get current UTC time here
}
无法从 activity 上下文中获取当前 UTC 时间。我应该如何获得它?
activity 函数可以自由使用 DateTime.UtcNow
或 DateTimeOffset.UtcNow
- 协调器只会 运行 它一次,然后记住后续重放的结果。 Orchestrator 函数必须使用确定性 IDurableOrchestrationContext.CurrentUtcDateTime
,因为重要的是 orchestrator 本身内的代码 returns 每次重播都具有相同的值。
所以我有一个看起来像这样的持久函数:
[FunctionName("functionName")]
public async Task functionName([OrchestrationTrigger] IDurableOrchestrationContext context)
{
// some code here
string name = "name";
await context.CallActivityAsync("activityFunction", name);
}
[FunctionName("activityFunction")]
public async Task ActivityFunction([ActivityTrigger] IDurableActivityContext name)
{
// perform an operation here
// need to get current UTC time here
}
无法从 activity 上下文中获取当前 UTC 时间。我应该如何获得它?
activity 函数可以自由使用 DateTime.UtcNow
或 DateTimeOffset.UtcNow
- 协调器只会 运行 它一次,然后记住后续重放的结果。 Orchestrator 函数必须使用确定性 IDurableOrchestrationContext.CurrentUtcDateTime
,因为重要的是 orchestrator 本身内的代码 returns 每次重播都具有相同的值。