Reputation: 43
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"
}
Upvotes: 0
Views: 1040
Reputation: 2792
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.
Upvotes: 1