OrchardCMS / OrchardCore

Orchard Core is an open-source modular and multi-tenant application framework built with ASP.NET Core, and a content management system (CMS) built on top of that framework.
https://orchardcore.net
BSD 3-Clause "New" or "Revised" License
7.35k stars 2.37k forks source link

Windows Docker image doesn't work with Sql Azure #10037

Open sebastienros opened 3 years ago

sebastienros commented 3 years ago

When starting an Orchard instance from the public docker image, trying to use SQL Azure results in this exception:

An error occurred while initializing the datastore: The instance of SQL Server you attempted to connect to requires encryption but this machine does not support it.

Root cause: https://github.com/dotnet/SqlClient/issues/714

sebastienros commented 3 years ago

Gopinadh is currently trying to apply this workaround 2 in a PR

string ManagedNetworkingAppContextSwitch = "Switch.Microsoft.Data.SqlClient.UseManagedNetworkingOnWindows";
AppContext.SetSwitch(ManagedNetworkingAppContextSwitch, true);

This could be added here:

https://github.com/OrchardCMS/OrchardCore/blob/339d74b251b53393dd510f8ad3027aa17d78500d/src/OrchardCore/OrchardCore.Data.YesSql/OrchardCoreBuilderExtensions.cs#L66

sebastienros commented 3 years ago

Because it's only happening on SQL Azure AND Windows Docker, we should try to detect this environment before applying this code. This is very rare since most docker hosts are Linux based.

SQL Azure can be detected with *.database.azure.com. Windows can be detected with System.Environment Docker can be detected with this ENV: DOTNET_RUNNING_IN_CONTAINER