How could you convert this in Azure storage v2.0 since "SetConfigurationSettingPublisher" was deleted ?
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
According to 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.
Depending on your application's requirements you might 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 the role instance is running, you can subscribe to the RoleEnvironment.Changing
and RoleEnvironment.Changed
events as described in Read Configuration Settings for the Storage Client Library and Handle Changed Settings and Responding to Role Topology Changes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With