How to correctly set up HTTP Webhook in Logic app to call a func app that is running for more than 5 mins?

Anisha Joseph 0 Reputation points
2023-01-31T04:03:16.5533333+00:00

Hi all,

I am trying to run a data-processing python code via the function app and logic app. The code processes more than 500K rows and o/p is around 450K records and takes around 5 mins to run.

The issue is that the function app runs fine but the logic app(Standard plan single tenant) fails due to timeout at 3min45 secs. The workaround I m trying to implement is using an HTTP Webhook instead of HTTP Trigger, but I am confused about how to return the 202 status code to the logic app and halt its clocking so that it waits for 5 mins and doesn't timeout.

I know there are better solutions other than the logic app for big data processing but my project doesn't have the necessary licences to use these, so we have to somehow implement using function apps and logic apps.

Kindly assist.

Thanks,

Anisha

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
2,827 questions
{count} votes

1 answer

Sort by: Most helpful
  1. VenkateshDodda-MSFT 17,911 Reputation points Microsoft Employee
    2023-01-31T11:36:09.3866667+00:00

    @Anisha Joseph Thank you for reaching out to Microsoft Q&A.

    You can refer to this documentation on how to create and run automated event based workflows using HTTP webhooks in logic apps.

    To test this behavior, we have created standard logic app workflow (using HTTP request trigger, HTTP webhook action) and function app (with HTTP trigger).

    User's image

    Whenever the Logic app got fired, HTTP Webhook, make a request to function app and function app will generate the callbackurl.

    Using another Http Client method, we will perform a post request to the generated callback Uri to complete the webhook action.

    Here is the function app code that we have used for testing:

    #r "Newtonsoft.Json"
    
    using System.Net;
    using System.Threading;
    using Microsoft.AspNetCore.Mvc;
    using Microsoft.Extensions.Primitives;
    using Newtonsoft.Json;
    
    public static async Task<IActionResult> Run(HttpRequest req, ILogger log)
    {
        log.LogInformation("C# HTTP trigger function processed a request.");
        
    string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
        HttpClient newClient = new HttpClient();
       HttpRequestMessage newRequest = new HttpRequestMessage(HttpMethod.Post,requestBody );
       HttpResponseMessage response = await newClient.SendAsync(newRequest);
       Thread.Sleep(10000);
        
        log.LogInformation(requestBody);
                return new OkObjectResult(requestBody);
    }
    
    

    Here is the sample output for your reference:
    User's image

    Feel free to reach back to me if you have any further questions on this.

    0 comments No comments