logic apps web hook to chalkboard API timeout error

删除回忆录丶 提交于 2021-02-10 14:32:58

问题


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"


回答1:


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

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:

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



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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!