gpt4 book ai didi

.net - Azure 存储 sdk v1.3 到 v2 => SetConfigurationSettingPublisher

转载 作者:行者123 更新时间:2023-12-04 14:14:16 27 4
gpt4 key购买 nike

自从“SetConfigurationSettingPublisher”被删除后,如何在 Azure 存储 v2.0 中转换它?

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();
}
}
};
}

);

谢谢

最佳答案

根据Windows Azure Storage Client Library 2.0 Breaking Changes & Migration Guide :

CloudStorageAccount.SetConfigurationSettingPublisher has been removed. Instead the members of StorageCredentials are now mutable allowing users to accomplish similar scenarios in a more streamlined manner by simply mutating the StorageCredentials instance associated with a given client(s) via the provided UpdateKey methods.

根据您的应用程序的要求,您可以直接使用 CloudConfigurationManager.GetSetting() 方法,如 Upgrading to Azure Storage Client 2.0 中所述。 :

var someSetting = CloudConfigurationManager.GetSetting(settingKey);

如果您需要在角色实例运行时响应配置更改,可以订阅 RoleEnvironment.ChangingRoleEnvironment.Changed Read Configuration Settings for the Storage Client Library and Handle Changed Settings中描述的事件和 Responding to Role Topology Changes .

关于.net - Azure 存储 sdk v1.3 到 v2 => SetConfigurationSettingPublisher,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17789937/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com