Transaction support in Azure WebJobs async functions

By : Nick

.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)

    await DoMoreWorkAsync(result, cancellationToken)

    scope.Complete(); // commit to perform all operations above


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?


It looks like Transactions (single-level) are supported with Service Bus queues (Standard tier) but not with Storage Queues. Ref: 'Foundational Capabilities' section at

By : Nick


Database access works the same way no matter who calls your code. Be it ASP.NET or WCF or some Azure framework.

You can indeed use transactions to make the work that you are performing atomic. This is basically a good thing. You can, for example, atomically check whether a given queue message or whatever already has been processed or not. If yet you simply bail out and you are idempotent that way.

The performance impact is not influenced by WebJobs. Transactions are exrtemely cheap except if you use distributed transaction which are to be avoided.

By : usr

This video can help you solving your question :)
By: admin