我有一个计时器触发器,它使用持久客户端调用协调器。有没有办法从协调器内部获取调用者函数的名称?
[FunctionName("Starter")]
public static async Task Starter(
[TimerTrigger("0 0 1 * * *", RunOnStartup = true)] TimerInfo myTimer,
[DurableClient] IDurableClient starter,
ILogger log)
{
await starter.StartNewAsync("Orchestrator", null);
}
[FunctionName("Orchestrator")]
public static async Task Orchestrator(
[OrchestrationTrigger] IDurableOrchestrationContext context)
{
// get caller function name here (Starter, in this example)
}
答案 0 :(得分:1)
只需将一个参数传递给协调器:
[FunctionName("Starter")]
public static async Task Starter(
[TimerTrigger("0 0 1 * * *", RunOnStartup = true)] TimerInfo myTimer,
[DurableClient] IDurableClient starter,
ILogger log)
{
await starter.StartNewAsync("Orchestrator", "NAME_OF_THE_CALLER");
}
[FunctionName("Orchestrator")]
public static async Task Orchestrator(
[OrchestrationTrigger] IDurableOrchestrationContext context)
{
// get caller function name here (Starter, in this example)
string caller = context.GetInput<string>();
}