我们最近将我们的ServiceStack应用程序转换为Azure云服务。ServiceStack + Azure云服务(CloudConfigurationManager)
我们发现,在内部,ServiceStack并不知道它需要使用CloudServiceConfiguration管理器而不是ConfigurationManager加载配置设置(如oauth.RedirectUrl)。
有没有办法连接适用于新环境的ServiceStack?
谢谢!
我们最近将我们的ServiceStack应用程序转换为Azure云服务。ServiceStack + Azure云服务(CloudConfigurationManager)
我们发现,在内部,ServiceStack并不知道它需要使用CloudServiceConfiguration管理器而不是ConfigurationManager加载配置设置(如oauth.RedirectUrl)。
有没有办法连接适用于新环境的ServiceStack?
谢谢!
有没有AppSettings provider为天青CloudServiceConfiguration,它应该很容易通过继承AppSettingsBase
和压倒一切的GetNullableString()
否则,最简单的方法就是来填充Dictionary<string,string>
从Azure的配置并加载它们为DictionarySettings
,比如建立一个:
AppSettings = new DictionarySettings(azureSettings);
如果你想两者的Web.config <appSettings/>
和Azure的设置在一起,你应该使用MultiAppSettings
使用您的APPHOST构造的AppSettings的级联来源,例如:
AppSettings = new MultiAppSettings(
new DictionarySettings(azureSettings),
new AppSettings());
您不需要使用'MultiAppSettings',因为CloudConfigurationManager将回退到您的配置设置部分。 (appsettings only)
从我的测试看来你似乎并不需要任何东西在asp.net 网站的web.config设置似乎得到某种方式与蔚蓝的设置覆盖。在webjob但是,您将需要使用CloudConfigurationManager ...下面是一个适当的实施服务栈AppSettings提供程序来包装它。
public class AzureCloudSettings : AppSettingsBase
{
private class CloudConfigurationManagerWrapper : ISettings
{
public string Get(string key)
{
return CloudConfigurationManager.GetSetting(key, false);
}
public List<string> GetAllKeys()
{
throw new NotImplementedException("Not possible with CloudConfigurationManager");
}
}
public AzureCloudSettings() : base(new CloudConfigurationManagerWrapper()) { }
public override string GetString(string name)
{
return GetNullableString(name);
}
public override string GetNullableString(string name)
{
return base.Get(name);
}
}
查看下方较近的答案,谢谢。 – Darren