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

问题描述 投票:0回答:1
我们有一个Azure函数应用程序,这将调用一个耐用的函数。调用

HttpTrigger

.
后,此耐用功能正在返回
HttpResponseData
我们无法创建自定义响应并仅从
CreateCheckStatusResponseAsync

中获得响应。

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

这是示例代码:

CreateCheckStatusResponseAsync

我们期望的反应应该是这样:

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

enter image description here当您打电话时// 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); }

c# .net azure azure-functions
1个回答
0
投票
只是scheduling

启动编排。这将需要有限的时间。 nime,尽管您可能还没有时间开始检查编排状态。

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

better:使您的功能返回202所接受的响应

^1

,并使用另一个URL(另一个功能)来检查编排的状态,并将该代码移至此处。
  1. 
    
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.