Skip to content

Latest commit

 

History

History
41 lines (27 loc) · 2.38 KB

File metadata and controls

41 lines (27 loc) · 2.38 KB
title summary component versions reviewed related redirects
SQL Azure
How to configure the NHibernate-based persistence for NServiceBus when running on SQL Azure
NHibernate
[6,]
2025-03-24
persistence/nhibernate/accessing-data
nservicebus/nhibernate/sql-azure

NHibernate persistence works with SQL Azure without needing to make any changes to code or configuration. However, there are considerations that should be taken into account when using a remote database.

Relational database as a service

When using a relational database as a service for persisting NServiceBus data, it is important to keep in mind that this type of data store has different runtime semantics than a traditional relational database.

  • The data store is potentially located in a remote location and is thus subject to a broad range of potential networking issues.
  • 'As a service' environments such as SQL Azure are typically shared environments, so performance of the database can be impacted by the behavior of other databases on the server.

The combination of these characteristics means that any transaction executed against the database may show intermittent exceptions. Usually these exceptions are transient in nature and can be resolved by retrying the transaction. A good place to start is the Transient Fault Handling documentation from Microsoft.

NHibernate specifics

As these exceptions can occur anywhere, they are best dealt with at the generic infrastructure level, using an NHibernate driver.

The NHibernate community has created a driver specific for SQL Azure called NHibernate.SqlAzure. This driver leverages the Microsoft Transient Fault Handling library to ensure reliable SQL Azure connections.

NuGet packages

There are two choices of package for this library.

Usage

After installation of the package, enable the driver by setting the NHibernate connection.driver_class property:

snippet: SqlAzureNHibernateDriverConfiguration