.net Azure存储sdk v1.3至v2=>;SetConfigurationSettingPublisher
自从“SetConfigurationSettingPublisher”被删除后,您如何在Azure storage v2.0中转换它.net Azure存储sdk v1.3至v2=>;SetConfigurationSettingPublisher,.net,azure,azure-storage,.net,Azure,Azure Storage,自从“SetConfigurationSettingPublisher”被删除后,您如何在Azure storage v2.0中转换它 CloudStorageAccount.SetConfigurationSettingPublisher( ( configName, configSetter ) => { // Provide the configSetter with the initial value configSetter( RoleEnvironment.GetCo
CloudStorageAccount.SetConfigurationSettingPublisher(
( configName, configSetter ) =>
{
// Provide the configSetter with the initial value
configSetter( RoleEnvironment.GetConfigurationSettingValue( configName ) );
RoleEnvironment.Changed += ( sender, arg ) =>
{
if( arg.Changes.OfType<RoleEnvironmentConfigurationSettingChange>( ).Any( (change) =>
( change.ConfigurationSettingName == configName ) ) )
{
// The corresponding configuration setting has changed, so propagate the value
if( !configSetter( RoleEnvironment.GetConfigurationSettingValue( configName ) ) )
{
// In this case, the change to the storage account credentials in the
// service configuration is significant enough that the role needs to be
// recycled in order to use the latest settings (for example, the
// endpoint may have changed)
RoleEnvironment.RequestRecycle();
}
}
};
}
CloudStorageAccount.SetConfigurationSettingPublisher(
(configName,configSetter)=>
{
//向configSetter提供初始值
configSetter(RoleEnvironment.GetConfigurationSettingValue(configName));
RoleEnvironment.Changed+=(发送方,参数)=>
{
if(arg.Changes.OfType().Any((change)=>
(change.ConfigurationSettingName==configName)))
{
//相应的配置设置已更改,因此传播该值
如果(!configSetter(RoleEnvironment.GetConfigurationSettingValue(configName)))
{
//在这种情况下,对存储帐户凭据的更改
//服务配置的重要性足以使角色
//回收以使用最新设置(例如
//端点可能已更改)
RoleEnvironment.RequestRecycle();
}
}
};
}
))
感谢根据:
CloudStorageAccount.SetConfigurationSettingPublisher已被删除。相反,的成员现在是可变的,允许用户通过提供的UpdateKey方法简单地改变与给定客户机关联的StorageCredentials实例,以更简化的方式完成类似的场景
根据应用程序的要求,您可以直接使用CloudConfigurationManager.GetSetting()
方法,如中所述:
如果需要在角色实例运行时响应配置更改,则可以订阅和中所述的和事件
var someSetting = CloudConfigurationManager.GetSetting(settingKey);