之后,此耐用功能正在返回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);
}输出响应我们的期望是以下: 当您打电话时
Task.Delay
只是scheduling启动编排。这将需要有限的时间。 nime,尽管您可能还没有时间开始检查编排状态。 有一些解决方案。
不太优雅:安排编排后加入几秒钟,以便花时间开始。这很糟糕,因为不能保证您需要等待多长时间,以便有时会失败。它将减慢您的HTTP请求。
better:使您的功能返回202所接受的响应