简体   繁体   English

如何调用 http 触发 azure function 从定时器触发 azure function

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

相关问题 计时器触发 Azure function 活动。当前为 null - Timer triggered Azure function Activity.Current is null Azure Function 未被触发 - Blob 存储触发器 - Azure Function is not getting triggered - Blob Storage Trigger 从外部 VM 在 Azure Win VM 上执行 bat 文件并由 Azure Function 触发的最佳和最安全的方法是什么 - What is the best and securest way to execute bat file on a Azure Win VM from outside VM and triggered by an Azure Function 为什么这个 Azure 时间触发 function 不会失败? - Why won't this Azure time triggered function fail? 如何管理并发 Http 触发的 Azure 函数的数据? - How to manage data on concurrent Http Triggered Azure Functions? 连续 Azure 具有 Http 触发函数的 WebJob - Continuous Azure WebJob with Http Triggered Functions 如何获取触发 Azure Function Blob 触发器的文件名 - How do I get the file name that triggered a Azure Function Blob Trigger 自定义 Azure 定时器触发函数 CRON 值 - Customizing Azure timer-triggered functions CRON value azure定时器function如何设置多个时间表? - How to set multiple schedule in azure timer function? Http 触发 function 存储输入绑定错误 - Http triggered function with Storage input binding error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM