问题
How are we supposed to handle transactions when having multiple output bindings in an Azure function and i have to guarantee that writing to all of the outputs has succeeded? Does the runtime provide some sort of distributed transaction handling or do i have to build everything myself?
For example i have a binding to DocumentDb and to Blob Storage. For some reason writing to Blob Storage fails. Is there a possiblity to rollback the whole operation?
回答1:
Runtime does not provide any transactional guarantees between multiple outputs. If first output succeeds, and then second one fails, you might end up in inconsistent state.
One workaround is to use trigger type with retries (e.g. Service Bus), and make all outputs idempotent.
来源:https://stackoverflow.com/questions/49598746/transactions-in-azure-functions-with-multiple-outputs