简体   繁体   English

Azure函数-持久函数,SetCustomStatus不更新

[英]Azure functions - durable functions, SetCustomStatus not updating

I created a durable function based on Microsoft examples from the pattern of "Async HTTP APIs". 我根据“异步HTTP API”模式下的Microsoft示例创建了持久功能。

In my code flow I wish to update the "SetCustomStatus" without using the "await contextReq.CallActivityAsync". 在我的代码流中,我希望不使用“ await contextReq.CallActivityAsync”来更新“ SetCustomStatus”。

Is it possible? 可能吗? since my durable function stays in "Pending" status, and the "customStatus" doesn't get updated. 因为我的持久功能保持“待处理”状态,并且“ customStatus”没有更新。

Some code snippet: 一些代码片段:

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

     }

This may be answered here: https://social.msdn.microsoft.com/Forums/en-US/767d5be5-4ba9-4b53-9838-9e32dfa7bdb3/azure-functions-durable-functions-setcustomstatus-not-updating?forum=AzureFunctions . 可以在这里回答: https : //social.msdn.microsoft.com/Forums/en-US/767d5be5-4ba9-4b53-9838-9e32dfa7bdb3/azure-functions-durable-functions-setcustomstatusus-not-updating?forum= AzureFunctions

To copy the answer -- 复制答案-

I don't believe the status is persisted anywhere until the activity is called. 我不认为该状态会在调用该活动之前一直存在。 So if you never call one, it will never be updated. 因此,如果您从未调用过它,它将永远不会被更新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM