.NET Framework 4.5.1 introduced transaction support in async methods, for example:
using (var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
{
var result = await DoWorkAsync(cancellationToken)
.ConfigureAwait(false);
await DoMoreWorkAsync(result, cancellationToken)
.ConfigureAwait(false);
scope.Complete(); // commit to perform all operations above
}
Ref: https://msdn.microsoft.com/en-us/library/dn261473(v=vs.110).aspx
Can this be used in Azure WebJobs async functions as well, to tighten the unit of work and provide better idempotent operations in case of host shutdown? And if so, will it have any impact on the performance?
Update:
It looks like Transactions (single-level) are supported with Service Bus queues (Standard tier) but not with Storage Queues. Ref: 'Foundational Capabilities' section at https://msdn.microsoft.com/en-us/library/azure/hh767287.aspx