0

There is a timer function, which in the middle of its work should call the http triggered (post request) function. How to do it? Will Durable function - chaining pattern help? How to pass parameters (in requestBody) to the called function? p.s. I apologize if I expressed myself illiterately in this matter.

Investigated the implementation of the chaining pattern. In the examples there was only a function of type Activity Trigger.

2 Answers2

0

How to do it? - You will submit a WebRequest from the timer triggered function to the http triggered function.

Will Durable function - chaining pattern help? - 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? - The documentation for webrequest provides some examples

Oxymoron
  • 1,380
  • 2
  • 19
  • 47
0

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. and I followed @Thiago Custodio SO-Thread as below:

    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);
                }
            }
        }
    }

enter image description here

RithwikBojja
  • 5,069
  • 2
  • 3
  • 7
  • Could you please suggest how should I implement authorization so that I can call a function from azure? In the example you refer to, a local call occurs. – nikita manzhosov Jan 24 '23 at 16:42
  • Check this SO #[75181464](https://stackoverflow.com/q/75181464/16630138) regarding implementation of security like Authorization on Azure Functions – RithwikBojja Jan 25 '23 at 07:30