我根据Microsoft示例通过“异步HTTP API”模式创建了持久功能。
在我的代码流中,我希望不使用“ await contextReq.CallActivityAsync”来更新“ SetCustomStatus”。
有可能吗?因为我的持久功能保持“待处理”状态,并且“ customStatus”没有更新。
一些代码段:
[FunctionName("UpdateItemsWithProgress")]
public static async Task<HttpResponseMessage> HttpStart(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")]HttpRequestMessage req,
[OrchestrationClient]DurableOrchestrationClient starter,
ILogger log)
{
dynamic jsonMessage = await req.Content.ReadAsAsync<object>();
try
{
string contentType = req.Content.Headers?.ContentType?.MediaType;
if (contentType == "application/json")
{
string instanceId = await starter.StartNewAsync("updateTransitItem", jsonMessage);
log.LogInformation($"Started orchestration with ID = '{instanceId}'.");
return starter.CreateCheckStatusResponse(req, instanceId);
} else
{
return starter.CreateCheckStatusResponse(req, null);
}
}
catch (Exception e)
{
return starter.CreateCheckStatusResponse(req, e.Message);
}
}
[FunctionName("updateTransitItem")]
public static async Task<object> RunOrchestrator(
[OrchestrationTrigger] DurableOrchestrationContext contextReq)
{
dynamic dynObj = contextReq.GetInput<object>();
contextReq.SetCustomStatus("Working...");
// doing stuff
contextReq.SetCustomStatus("1");
// doing stuff
contextReq.SetCustomStatus("2");
// doing stuff
return "Success"
}
答案 0 :(得分:1)
要复制答案-
我不认为该状态会在调用该活动之前一直存在。因此,如果您从不呼叫一个,它将永远不会被更新。