[英]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.