diff --git a/src/Orchard.Web/Modules/Orchard.Azure/Orchard.Azure.csproj b/src/Orchard.Web/Modules/Orchard.Azure/Orchard.Azure.csproj index f2f4cbc34..a37eca615 100644 --- a/src/Orchard.Web/Modules/Orchard.Azure/Orchard.Azure.csproj +++ b/src/Orchard.Web/Modules/Orchard.Azure/Orchard.Azure.csproj @@ -90,6 +90,7 @@ ..\..\..\..\lib\nhibernate\NHibernate.dll + diff --git a/src/Orchard.Web/Modules/Orchard.Azure/Services/Environment/Configuration/DefaultPlatformConfigurationAccessor.cs b/src/Orchard.Web/Modules/Orchard.Azure/Services/Environment/Configuration/DefaultPlatformConfigurationAccessor.cs index b185f07b1..cbe688827 100644 --- a/src/Orchard.Web/Modules/Orchard.Azure/Services/Environment/Configuration/DefaultPlatformConfigurationAccessor.cs +++ b/src/Orchard.Web/Modules/Orchard.Azure/Services/Environment/Configuration/DefaultPlatformConfigurationAccessor.cs @@ -1,21 +1,29 @@ using Microsoft.WindowsAzure; +using System.Configuration; namespace Orchard.Azure.Services.Environment.Configuration { public class DefaultPlatformConfigurationAccessor : IPlatformConfigurationAccessor { /// - /// Reads a setting from platform configuration, trying first prefixed with the current tenant name and - /// secondly with no prefix. + /// Trying to read a setting from the following sources in the following order (with and then without tenant name prefix): + /// CloudConfigurationManager, ConnectionStrings, AppSettings. /// /// The name of the setting to read. - /// The curren tenant's name. + /// The current tenant's name. /// An optional prefix to prepend the setting name with. - /// The value of the setting if found with or without tenant name prefix, otherwise null. + /// The value of the setting if found in any of the available sources, otherwise null. public string GetSetting(string name, string tenant, string namePrefix = null) { var tenantName = tenant + ":" + (namePrefix ?? string.Empty) + name; var fallbackName = (namePrefix ?? string.Empty) + name; - return CloudConfigurationManager.GetSetting(tenantName) ?? CloudConfigurationManager.GetSetting(fallbackName); + + var settingFromCloudConfiguration = CloudConfigurationManager.GetSetting(tenantName) ?? CloudConfigurationManager.GetSetting(fallbackName); + if (!string.IsNullOrEmpty(settingFromCloudConfiguration)) return settingFromCloudConfiguration; + + var settingFromConnectionStrings = ConfigurationManager.ConnectionStrings[tenantName] ?? ConfigurationManager.ConnectionStrings[fallbackName]; + if (settingFromConnectionStrings != null) return settingFromConnectionStrings.ConnectionString; + + return ConfigurationManager.AppSettings[tenantName] ?? ConfigurationManager.AppSettings[fallbackName]; } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Azure/Services/Environment/Configuration/IPlatformConfigurationAccessor.cs b/src/Orchard.Web/Modules/Orchard.Azure/Services/Environment/Configuration/IPlatformConfigurationAccessor.cs index 3beec81d7..4149f7d80 100644 --- a/src/Orchard.Web/Modules/Orchard.Azure/Services/Environment/Configuration/IPlatformConfigurationAccessor.cs +++ b/src/Orchard.Web/Modules/Orchard.Azure/Services/Environment/Configuration/IPlatformConfigurationAccessor.cs @@ -6,7 +6,7 @@ /// Reads a setting using the available implementation(s). /// /// The name of the setting to read. - /// The curren tenant's name. + /// The current tenant's name. /// An optional prefix to prepend the setting name with. /// The value of the setting if found with or without tenant name prefix, otherwise null. ///