0 out of 5 rated this helpful - Rate this topic

CloudStorageAccount.SetConfigurationSettingPublisher Method

Sets the global configuration setting publisher for the storage account, which will be called when the account access keys are updated in the service configuration file.

Namespace: Microsoft.WindowsAzure
Assembly: Microsoft.WindowsAzure.StorageClient (in Microsoft.WindowsAzure.StorageClient.dll)
'Usage
Dim configurationSettingPublisher As Action(Of String, Func(Of String, Boolean))

CloudStorageAccount.SetConfigurationSettingPublisher(configurationSettingPublisher)
public static void SetConfigurationSettingPublisher (
	Action<string,Func<string,bool>> configurationSettingPublisher
)
public static void SetConfigurationSettingPublisher (
	Action<String,Func<String,boolean>> configurationSettingPublisher
)
public static function SetConfigurationSettingPublisher (
	configurationSettingPublisher : Action<String,Func<String,boolean>>
)

Parameters

configurationSettingPublisher

Type: System.Action

The configuration setting publisher for the storage account.

A configuration setting publisher allows adding subscribers for configuration settings. Subscribers are notified when a configuration setting changes, so that a role can determine whether or not to recycle on a given configuration change. This may be useful in the event that storage account access keys are regenerated and updated in a connection string in the service configuration file.

The following code sets a configurationSettingPublisher function by passing in an anonymous function created using nested lambda expressions. This handler function updates CloudStorageAccount instances when their corresponding configuration settings change in the service configuration file:

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

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Development Platforms

Windows Vista, Windows 7 and Windows Server 2008

Target Platforms

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ