We are currently using ReliableSqlConnection for all calls to our Azure SQL database. This works fine. But unfortunately the Enterprise Library is from 2013 and it seems not to be developed anymore. But the main issue is, that async db calls are not supported.
I've been searching SO and other places, but the only thing I could find so far was Polly. And even Polly does not seem to be widely used and I have not found an example for SQL Server. I know that ADO.NET supports retry for SqlConnection.Open(), but not for commands, so it's not a real solution. I'm a bit surprised that we seem to be the only ones having this problem?
Little known fact, transient fault tolerance is now built into the connection string (.NET 4.6.1+). This document says:
If your client program connects to to Azure SQL Database by using the .NET Framework class
System.Data.SqlClient.SqlConnection, you should use .NET 4.6.1 or later (or .NET Core) so you can leverage its connection retry feature. Details of the feature are here.When you build the connection string for your
SqlConnectionobject, you should coordinate the values among the following parameters:
ConnectRetryCount(Default is 1. Range is 0 through 255.)
ConnectRetryInterval(Default is 1 second. Range is 1 through 60.)
Connection Timeout(Default is 15 seconds. Range is 0 through 2147483647)Specifically, your chosen values should make the following equality true:
Connection Timeout = ConnectRetryCount * ConnectionRetryIntervalFor example, if the count = 3, and interval = 10 seconds, a timeout of only 29 seconds would not quite give the system enough time for its 3rd and final retry at connecting: 29 < 3 * 10.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With