[英]How to call http triggered azure function from timer triggered azure function
有一个计时器function,它在工作的中间应该调用http触发(post request)function。怎么做呢? Durable function - 链接模式有帮助吗? 如何将参数(在requestBody中)传递给被调用的function? ps如果我在这件事上表达不识字,我深表歉意。
研究了链接模式的实现。 在示例中,只有一个类型为 Activity Trigger 的 function。
怎么做? - 您将提交一个WebRequest从定时器触发 function 到 http 触发 function。
Durable function - 链接模式有帮助吗? - 可能不会,到目前为止你在问题陈述中没有提到任何让我相信改变你的模式会解决你的任何问题。
如何将参数(在requestBody中)传递给被调用的function? - webrequest 的文档提供了一些示例
正如@Oxymoron 建议的那样,您必须使用 Web 请求 Object 来发布 Http 触发器 URL/函数,并且您可以使用其中一种持久函数模式从计时器触发器调用 http 触发器 function。 我按照以下方式关注@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.