The Windows Azure CAT team has built a library (available via Nuget) that provides alot of functionality around handling transient connection problems across the Windows Azure Platform with SQL Azure, ServiceBus, Cache, Configuration and Storage supported (this has been around awhile but it’s the first chance I’ve had to try it out).
To use add the TransientFaultHandlingFx reference:

In addition to adding the assemblies it also adds a .chm to your project with full documentation on how to use the library.
There are numerous ways to actually use the library. For SQL Azure I would recommend reading the whitepaper the Windows Azure CAT team published.
The method I chose was to configure a retry policy in my web/app.config:
<configSections> <section name=”RetryPolicyConfiguration” type=”Microsoft.AzureCAT.Samples.TransientFaultHandling.Configuration.RetryPolicyConfigurationSettings, Microsoft.AzureCAT.Samples.TransientFaultHandling” /> </configSections> <RetryPolicyConfiguration defaultPolicy=”FixedIntervalDefault” defaultSqlConnectionPolicy=”FixedIntervalDefault” defaultSqlCommandPolicy=”FixedIntervalDefault” defaultStoragePolicy=”IncrementalIntervalDefault” defaultCommunicationPolicy=”IncrementalIntervalDefault”> <add name=”FixedIntervalDefault” maxRetryCount=”10″ retryInterval=”100″ /> <add name=”IncrementalIntervalDefault” maxRetryCount=”10″ retryInterval=”100″ retryIncrement=”50″ /> <add name=”ExponentialIntervalDefault” maxRetryCount=”10″ minBackoff=”100″ maxBackoff=”1000″ deltaBackoff=”100″ /> </RetryPolicyConfiguration>
From there it’s simple to create a RetryPolicy object from the configuration:
public static RetryPolicy GetRetryPolicy()
{
// Retrieve the retry policy settings from the application configuration file.
RetryPolicyConfigurationSettings retryPolicySettings = ApplicationConfiguration.Current.GetConfigurationSection<RetryPolicyConfigurationSettings>(RetryPolicyConfigurationSettings.SectionName);
// Retrieve the required retry policy definition by its friendly name.
RetryPolicyInfo retryPolicyInfo = retryPolicySettings.Policies.Get(“FixedIntervalDefault”);
// Create an instance of the respective retry policy using the transient error detection strategy for SQL Azure.
RetryPolicy sqlAzureRetryPolicy = retryPolicyInfo.CreatePolicy<SqlAzureTransientErrorDetectionStrategy>();
return sqlAzureRetryPolicy;
}
You can pass the RetryPolicy object to the extension methods (for ADO.NET in my example):
sqlCon.OpenWithRetry(rp); // for SqlConnection object rValue = sqlCmd.ExecuteScalarWithRetry(rp); // from SQLCommand
There is functionality for LINQ as well.
This library not only makes your code robust but can save you a massive amount of time too since they have already put the resources into testing/debugging it