[英]How to pass a POST parameter to a Durable Function and then pass this param to a Timer Triggered function
using System;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
namespace mynamespace
{
public static class myfuncclass
{
[FunctionName("mydurablefunc")]
public static async void Run([OrchestrationTrigger] DurableOrchestrationContextBase context)
{
await context.CallActivityAsync<string>("timer", "myparam");
}
[FunctionName("timer")]
public static void RunTimer([TimerTrigger("0 */5 * * * *")]TimerInfo myTimer, TraceWriter log)
{
if (myTimer.IsPastDue)
{
log.Info("Timer is running late!");
}
log.Info($"Timer trigger function executed at: {DateTime.Now}");
}
}
}
I want my Durable Function to start another function that is timer based, which has to reoccur every 5 minutes. 我希望我的耐用功能启动另一个基于计时器的功能,该功能必须每5分钟重新出现一次。 So far so good and this is my code.
到目前为止一切顺利,这是我的代码。 Now I want this activity to start when I call the Durable Function with HTTP call (POST, GET, whatever) (I preferred with Queue but don't know how to do it) and pass a parameter to it and then it passes this parameter to the invoked function.
现在,我希望通过HTTP调用持久功能(POST,GET等)启动此活动(我更喜欢Queue,但不知道如何执行)并向其传递参数,然后它传递此参数到调用的函数。 How?
怎么样?
You can't "start" Timer Trigger. 您不能“启动”计时器触发器。 Orchestrator can only manage Activity functions, like this:
Orchestrator只能管理Activity功能,如下所示:
[FunctionName("mydurablefunc")]
public static async void Run([OrchestrationTrigger] DurableOrchestrationContextBase context)
{
for (int i = 0; i < 10; i++)
{
DateTime deadline = context.CurrentUtcDateTime.Add(TimeSpan.FromMinutes(5));
await context.CreateTimer(deadline, CancellationToken.None);
await context.CallActivityAsync<string>("myaction", "myparam");
}
}
[FunctionName("myaction")]
public static Task MyAction([ActivityTrigger] string param)
{
// do something
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.