[英]How to call http triggered azure function from timer triggered azure function
There is a timer function, which in the middle of its work should call the http triggered (post request) function. How to do it?有一个计时器function,它在工作的中间应该调用http触发(post request)function。怎么做呢? Will Durable function - chaining pattern help?
Durable function - 链接模式有帮助吗? How to pass parameters (in requestBody) to the called function?
如何将参数(在requestBody中)传递给被调用的function? ps I apologize if I expressed myself illiterately in this matter.
ps如果我在这件事上表达不识字,我深表歉意。
Investigated the implementation of the chaining pattern.研究了链接模式的实现。 In the examples there was only a function of type Activity Trigger.
在示例中,只有一个类型为 Activity Trigger 的 function。
How to do it?怎么做? - You will submit a WebRequest from the timer triggered function to the http triggered function.
- 您将提交一个WebRequest从定时器触发 function 到 http 触发 function。
Will Durable function - chaining pattern help? Durable function - 链接模式有帮助吗? - Probably not, nothing you have mentioned so far in your problem statement leads me to believe that changing your pattern will address any of your concerns.
- 可能不会,到目前为止你在问题陈述中没有提到任何让我相信改变你的模式会解决你的任何问题。
How to pass parameters (in requestBody) to the called function?如何将参数(在requestBody中)传递给被调用的function? - The documentation for webrequest provides some examples
- webrequest 的文档提供了一些示例
As @Oxymoron suggested, you have to use Web Request Object to Post the Http Trigger URL/Function and you can use one of the durable functions patterns to call the http trigger function from the timer trigger.正如@Oxymoron 建议的那样,您必须使用 Web 请求 Object 来发布 Http 触发器 URL/函数,并且您可以使用其中一种持久函数模式从计时器触发器调用 http 触发器 function。 and I followed @Thiago Custodio SO-Thread as below:
我按照以下方式关注@Thiago Custodio SO-Thread :
namespace FunctionApp45
{
public class Function1
{
[FunctionName("Function1")]
public async Task RunAsync([TimerTrigger("*/30 * * * * *")]TimerInfo myTimer, ILogger log)
{
log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
var url = "https://www.google.co.in/";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.AutomaticDecompression = DecompressionMethods.GZip;
using (HttpWebResponse response = (HttpWebResponse)await request.GetResponseAsync())
using (Stream stream = response.GetResponseStream())
using (StreamReader reader = new StreamReader(stream))
{
var htmlrawdata = reader.ReadToEnd();
log.LogInformation(htmlrawdata);
}
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.