3

I am trying to store the time stamp information in durable entities and retrieve it every time a trigger fired. Here is how I am doing it. I want the timestamp value set by the current execution to be available for the next trigger. But when the control reaches "string prevTS = await context.CallEntityAsync(entityId, "Get");" to goes back to start of the function again. What am I missing here.

I want execution to be sequential between the timer triggers. '''

 ***public static class GetOpenDataRealtimeFeed
    {
        [FunctionName("GetOpenDataOrchestrator")]
        public static async Task<List<string>> RunOrchestrator(
            [OrchestrationTrigger] IDurableOrchestrationContext context, Binder binder, ILogger log)
        {
            var outputs = new List<string>();
            var entityId = new EntityId(nameof(GetPrevLastModifiedTimestamp), "entityKey2");
            string prevTS = await context.CallEntityAsync<string>(entityId, "Get");
            
            string currentTS = DateTime.Now.ToString();
            outputs.Add(currentTS);
            outputs.Add(prevTS);
            context.SignalEntity(entityId, "Set", currentTS);
            return null;

        }

        //Durable entity function to get & set the last modified timestamp
        [FunctionName("GetPrevLastModifiedTimestamp")]
        public static void GetPrevLastModifiedTimestamp([EntityTrigger] IDurableEntityContext ctx)
        {
            switch (ctx.OperationName.ToLowerInvariant())
            {
                case "set":
                    ctx.SetState(ctx.GetInput<string>());
                    break;
                case "get":
                    ctx.Return(ctx.GetState<string>());
                    break;
            }
        }


        [FunctionName("getOpenDataRealtimeFeed_Trigger")]
        public static async Task Run(
            [TimerTrigger("%triggerTimer%")] TimerInfo myTimer,
            [DurableClient] IDurableOrchestrationClient starter,
            ILogger log)
        {
            // Function input comes from the request content.
            string instanceId = await starter.StartNewAsync("GetOpenDataOrchestrator", null);
            log.LogInformation($"Started orchestration with ID = '{instanceId}'.");
        }
    }
}*** 

'''

1
  • you can also use context.IsReplaying property on the IDurableOrchestrationContext interface. this property will show you if it's the actual execution vs, the replay to reach the next "await" Commented Oct 23, 2020 at 7:25

1 Answer 1

1

I assume you are referring to the current line while debugging. If so, this is expected.

Since Durable Functions replays functions after awaiting a durable client call, execution won't ever go through the first round. Only the final replay will be "sequential" step overs.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.