简体   繁体   中英

Azure functions - durable functions, SetCustomStatus not updating

I created a durable function based on Microsoft examples from the pattern of "Async HTTP APIs".

In my code flow I wish to update the "SetCustomStatus" without using the "await contextReq.CallActivityAsync".

Is it possible? since my durable function stays in "Pending" status, and the "customStatus" doesn't get updated.

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 .

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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