如何自定义来自.net8隔离工作过程中的HTTPTRIGGER AZURE函数应用程序的响应

问题描述 投票:0回答:1
我们有一个httptrigger函数应用程序,这正在调用耐用函数, 拨打CreateCheckStatusResponsync

之后,此耐用功能正在返回HttPresponSedata

因此,现在我们无法创建自定义响应并仅从CreateCheckStatusResponSeaseNC中获得响应。

请建议如何自定义此响应。

添加示例代码下方

//function app [Function("HelloCities_HttpStart")] public static async Task<HttpResponseData> HttpStart( [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestData req, [DurableClient] DurableTaskClient client, FunctionContext executionContext) { ILogger logger = executionContext.GetLogger("HelloCities_HttpStart"); // Function input comes from the request content. string instanceId = await client.ScheduleNewOrchestrationInstanceAsync(nameof(HelloCities)); logger.LogInformation("Started orchestration with ID = '{instanceId}'.", instanceId); // Returns an HTTP 202 response with an instance management payload. // See https://learn.microsoft.com/azure/azure-functions/durable/durable-functions-http-api#start-orchestration return await client.CreateCheckStatusResponseAsync(req, instanceId);

}
输出响应我们的期望是以下:

enter image description here但是我们得到的回应是:

enter image description here

当您打电话时
c# .net azure azure-functions
1个回答
0
投票

Task.Delay

只是scheduling
启动编排。这将需要有限的时间。 nime,尽管您可能还没有时间开始检查编排状态。 有一些解决方案。

不太优雅:安排编排后加入几秒钟,以便花时间开始。这很糟糕,因为不能保证您需要等待多长时间,以便有时会失败。它将减慢您的HTTP请求。

better:使您的功能返回202所接受的响应
    ^1
  1. ,并使用另一个URL(另一个功能)来检查编排的状态,并将该代码移至此处。

        

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.