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.

4
  • 1
    Just create an HttpClient and call the function. Commented Jan 24, 2023 at 14:15
  • 1
    ^^ "Create" as in: Have one injected. Commented Jan 24, 2023 at 14:41
  • Are they in the same function app? Also, is it C# script or compiled from VS/VS Code? I ask because I don’t think you’re seeing the forest for the trees and I’ll have a better way to do it depending on your answer. Commented Jan 24, 2023 at 19:48
  • these two functions are in different function app. I use .NET 6.0 (c#) to implement azure functions. Commented Jan 24, 2023 at 21:39

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

Comments

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

2 Comments

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.
Check this SO #75181464 regarding implementation of security like Authorization on Azure Functions

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.