Search code examples
transactionsazure-functionsdynamics-365

How to implement transaction in Azure Function?


How to keep multiple actions in one transaction? anyone is failed, I want to roll back the whole operation. e.g. Action 1 is to write a record to Azure Table. Action 2 is to write a record to D365.


Solution

  • Have you looked at durable functions? https://learn.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-error-handling?tabs=csharp

    Any exceptions are marshaled back to to the orchestrator so you will need to catch and handle each type for failure and "roll back" the completed actions yourself.

    There is the idea of a transaction in Dynamics, https://learn.microsoft.com/en-us/power-apps/developer/data-platform/org-service/use-executetransaction

    It will roll back ONLY what occurred during that transaction and ONLY in Dynamics. Its not really recommended, generally MS recommends that we send each request to the API as single requests, and a ExecuteTransaction Request locks the records in the transaction, so likely to have performance impact.