Azure Storage Persistence

Project Hosting
NuGet NServiceBus.Azure (6.x)
Target NServiceBus Version: 5.x

Certain features of NServiceBus require persistence to permanently store data. Among them are subscription storage, sagas, and timeouts. Various storage options are available including Azure Storage Services.

Enable Azure Storage Persistence

First add a reference to the assembly that contains the Azure storage persisters, which is done by adding a NuGet package reference to NServiceBus.Azure.

busConfiguration.UsePersistence<AzureStoragePersistence>();

Saga correlation

One of the limitations of the Azure Storage Persistence is support for only one [Unique] property (a saga property which value is guaranteed to be unique across all sagas of this type).

To ensure that only one saga can be created for one correlation property value, secondary indexes have been introduced. Their entities are stored in the same table as a saga. When a saga is completed, a secondary index entity is removed as well. It's possible, but highly unlikely, that the saga's completion can leave an orphaned secondary index record. This does not impact the behavior of the persistence as it can detect orphaned records, but may leave a dangling entity in a table with a following WARN entry in logs: Removal of the secondary index entry for the following saga failed: {sagaId}.

If a migration from 6.2.3 or earlier to a newer version was performed without applying saga deduplication, DuplicatedSagaFoundException can be observed because of duplicates violating a unique property of a saga. The exception message will include all the information to track down the error for example:

Sagas of type MySaga with the following identifiers 'GUID1', 'GUID2' are considered duplicates because of the violation of the Unique property CorrelationId.`

The way to address them is go through the upgrade guide linked above.

Supported saga properties' types

Azure Storage Persistence supports exactly the same set of types as Azure Table Storage. When a saga containing a property of an unsupported type is persisted, an exception containing a following information is thrown: The property type 'the_property_name' is not supported in windows azure table storage. If an object of a non-supported type is required to be stored, then it's a user responsibility to serialize/deserialize the value.

Related Articles


Last modified