user7454972
user7454972

Reputation: 218

Azure Function store requests and trigger the funtion again later

I have an Azure Function that will take a POST request , do some processing and then sends a POST to another Endpoint with the content of the input request.

I have the requirement, that I somehow have to store all the incoming requests and after a fixed time period the Azure Function needs to send the same POST request again.

What I could do is, set up a cloud storage where I store all the incoming requests and have a second Azure Function with a timer trigger that reads from the storage and sends the request again. My problem with this is, that I have to set up an additional storage and I am looking for a more cost efficient method.

Does anyone know an alternative way to "store" incoming requests and have the same Azure Funtion pick them up again later?

Upvotes: 1

Views: 307

Answers (1)

Matt
Matt

Reputation: 13399

Sounds like what you're looking for is durable functions which can handle exactly this kind of scenario and it'll do all the complicated parts of storing state/context during delays. They are backed by Azure storage but as has been said this is one of the cheapest services available on Azure.

For what you've described you might want to do a combination of function chaining:

enter image description here

Combined with a timer in between the processing you do in chained functions:

//do some initial processing (possibly in an Activity function)
//...

DateTime waitTime = context.CurrentUtcDateTime.Add(TimeSpan.FromDays(1));
await context.CreateTimer(waitTime, CancellationToken.None);

//call the next activity function (parameters can also be passed in)
await context.CallActivityAsync("DoNextSetOfThings");

High level what you'd have is something along the lines of:

  1. An HTTP endpoint which you POST to initially
  2. An Orchestrator function which handles the chaining and delays
  3. One or more Activity functions that do the work and can accept parameters and return results to the Orchestrator

Upvotes: 1

Related Questions