0

I have following type of 3rd party APIs to be called in sequence in c# code.

try
{
    transaction:
    {
        call API 1;
        call API 2
        call API 3
    }

}
Catch
{
    transaction rollback:
    rollback API 4;
    rollback API 5;
}

How should I handle this in Azure function http trigger? Is SAGA or 2 phase commit suitable here? are Azure durable functions suitable? Any other pattern can I use for this?

James Z
  • 12,209
  • 10
  • 24
  • 44
P Deshpande
  • 457
  • 1
  • 4
  • 6

1 Answers1

0

As you replied that API 1,2,3 return very quickly and I assume they can run in parallel, then I would simply use a Task.WhenAll and perform any necessary rollback if any of them return an Exception (as their means of signalling failure).

Durable Functions could be used, but it sounds like overkill in this scenario. Durable Function are used for more long-lived scenarios

Rex Henderson
  • 412
  • 2
  • 7