Azure storage sdk v1.3 to v2 => SetConfigurationSettingPublisher

How could you convert this to Azure storage v2.0 since "SetConfigurationSettingPublisher" has been removed?

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

);

thanks

+6
source share
1 answer

According to the Windows Azure Storage Client Library 2.0 Change and Migration Guide :

CloudStorageAccount.SetConfigurationSettingPublisher has been deleted. Instead, the members of the StorageCredentials are now being changed, allowing users to run similar scripts in a more orderly fashion by simply modifying the StorageCredentials instance associated with the client (s) data using the provided UpdateKey methods.

Depending on your application requirements, you can simply use the CloudConfigurationManager.GetSetting() method directly, as described in Upgrading to Azure Storage Client 2.0 :

 var someSetting = CloudConfigurationManager.GetSetting(settingKey); 

If you need to respond to configuration changes while starting the role instance, you can subscribe to RoleEnvironment.Changing and RoleEnvironment.Changed , as described in Read configuration settings for the warehouse client library and process the changed settings and Respond to role topology changes .

+9
source

Source: https://habr.com/ru/post/949993/


All Articles