逻辑应用程序 Web 挂钩到黑板 API 超时错误

logic apps web hook to chalkboard API timeout error

如何更改逻辑应用程序 Web 挂钩和黑板中的超时持续时间 API。

我得到的错误信息是。

"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"

可以参考Perform long-running tasks with the webhook action pattern.

了解了webhook模式后,还需要设计一些代码,可以参考下面的示例:

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

}

上面的代码会先把你的callbackUrl和传过来的数据存到队列中,然后return把202的结果存到逻辑app中

即将触发QueueTrigger功能,您可以在这里办理业务。

您可以在 Azure 逻辑应用程序中像这样调用您的 http 函数:

本方案可以帮助您解决http超时问题。更详细的可以参考这个article.