1
votes

We have an ASP.NET MVC 3 web site which isn't working after it's deployed to the Azure Cloud Services. During development, we've been testing it using the Azure Web Sites platform but in order to get the SSL support for our custom domain, we are now trying to deploy it to Web Role in Cloud Services. But the site's database connection to SQL Azure doesn't work, instead we get: "The instance of SQL Server you attempted to connect to does not support encryption." Retrying the connection doesn't work, that error message persists.

To summarize, here's the platforms where the site works and where it doesn't:

  • Azure Emulator: Works
  • Azure Web Sites: Works
  • Azure Cloud Services (Web Role): Doesn't work

The "How to: Connect to Windows Azure SQL Database Using ADO.NET" states that the error "The instance of SQL Server you attempted to connect to does not support encryption." "indicates a failure during the login process, and is not an encryption failure. Beginning in .NET 4.5, ADO.NET displays a better error message." The Azure Cloud Services are limited to .NET 4.0.

The site is using NHibernate to connect to the DB. Here's an error from the log file:

Creating nhibernate session factory failed. FluentNHibernate.Cfg.FluentConfigurationException: An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.

  • Database was not configured through Database method. ---> System.Data.SqlClient.SqlException: The instance of SQL Server you attempted to connect to does not support encryption. at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) at System.Data.SqlClient.SqlConnection.Open() at YoureOnTime.Data.RetryConnectionStringProvider.<>c_DisplayClass2.b_0() at YoureOnTime.Common.Retry.RequestWithRetry(RetryPolicy retryPolicy, Action action) at YoureOnTime.Data.RetryConnectionStringProvider.GetConnection() at NHibernate.Tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.Prepare() at NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.GetReservedWords(Dialect dialect, IConnectionHelper connectionHelper) at NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.Update(ISessionFactory sessionFactory) at NHibernate.Impl.SessionFactoryImpl..ctor(Configuration cfg, IMapping mapping, Settings settings, EventListeners listeners) at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() --- End of inner exception stack trace ---

And here's how the connection is defined in the hibernate.xml:

<property name="connection.connection_string">
      data source=database.database.windows.net;Initial Catalog=db;User ID=user;Password=password;Encrypt=true;Trusted_Connection=false;MultipleActiveResultSets=True
</property>

Any ideas?

1

1 Answers

0
votes

Bases on my previous experience on seeing this error, it is an intermittent occurrence. SQL Database always enforces encryption and if during an early phase of the login process (before authentication) there is a failure, the protocol libraries (client side) will fall back to this error message. As you mentioned it is a misleading message and not related to encryption.

This article described the exact same error and explains how you can solve your problem by adding retry logic. So if you modify your code to use retry logic, after a few failure you may pass this error and get the connection going.