Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
524 views
in Technique[技术] by (71.8m points)

webhooks - logic apps web hook to chalkboard API timeout error

How do I change the timeout duration in logic apps web hook and also in chalkboard API.

The error message I get is.

"message": "Http request failed: the server did not respond within the timeout limit. Please see logic app limits at https://aka.ms/logic-apps-limits-and-config#http-limits"

question from:https://stackoverflow.com/questions/65883028/logic-apps-web-hook-to-chalkboard-api-timeout-error

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can refer to Perform long-running tasks with the webhook action pattern.

enter image description here

After understanding the webhook pattern, you need to design some code, you can refer to the following sample:

using System.IO;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Azure.WebJobs.Host;
using Newtonsoft.Json;
using System.Threading;
using System.Net.Http;
using System;

namespace HttpToQueueWebhook
{
    public static class HttpTrigger
    {
        [FunctionName("HttpTrigger")]
        public static IActionResult Run(
            [HttpTrigger(AuthorizationLevel.Function, "post")]HttpRequest req, 
            TraceWriter log,
            [Queue("process")]out ProcessRequest process)
        {
            log.Info("Webhook request from Logic Apps received.");

            string requestBody = new StreamReader(req.Body).ReadToEnd();
            dynamic data = JsonConvert.DeserializeObject(requestBody);
            string callbackUrl = data?.callbackUrl;

            //This will drop a message in a queue that QueueTrigger will pick up
            process = new ProcessRequest { callbackUrl = callbackUrl, data = "some data" };
            return new AcceptedResult();
        }

        public static HttpClient client = new HttpClient();

        /// <summary>
        /// Queue trigger function to pick up item and do long work. Will then invoke
        /// the callback URL to have logic app continue
        /// </summary>
        [FunctionName("QueueTrigger")]
        public static void Run([QueueTrigger("process")]ProcessRequest item, TraceWriter log)
        {
            log.Info($"C# Queue trigger function processed: {item.data}");
            //Thread.Sleep(TimeSpan.FromMinutes(3));
            //ProcessResponse result = new ProcessResponse { data = "some result data" };
            
            
            //handle your business here.
            
            
            client.PostAsJsonAsync<ProcessResponse>(item.callbackUrl, result);
        }
    }

    public class ProcessRequest
    {
        public string callbackUrl { get; set; }
        public string data { get; set; }
    }

    public class ProcessResponse
    {
        public string data { get; set; }
    }

}

The above code will first save your callbackUrl and the passed data to the queue, and then return the result of 202 to the logic app.

The QueueTrigger function will be triggered, and you can handle your business here.

You can call your http function like this in Azure logic app:

enter image description here

This solution can help you solve the http timeout problem. For more details, you can refer to this article.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...