CloudStorageAccount.SetConfigurationSettingPublisher Method

Storage Client Library NET API

[This topic is part of the Microsoft Azure Storage Client Library 1.7, which has been deprecated. See Storage Client Library for the latest version.]

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

Visual Basic
Dim configurationSettingPublisher As Action(Of String, Func(Of String, Boolean))

CloudStorageAccount.SetConfigurationSettingPublisher(configurationSettingPublisher)

Syntax

Visual Basic
Public Shared Sub SetConfigurationSettingPublisher ( _
	configurationSettingPublisher As Action(Of String, Func(Of String, Boolean)) _
)
C#
public static void SetConfigurationSettingPublisher (
	Action<string,Func<string,bool>> configurationSettingPublisher
)
C++
public:
static void SetConfigurationSettingPublisher (
	Action<String^, Func<String^, bool>^>^ configurationSettingPublisher
)
J#
JScript

Parameters

configurationSettingPublisher

Type: System.Action

The configuration setting publisher for the storage account.

Remarks

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:

C# Copy Code
  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();
          }
        }
      };
    }
  );

Thread Safety

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

Platforms

Development Platforms

Windows Vista, Windows 7, Windows Server 2008, Windows 8.1, Windows Server 2012 R2, Windows 8 and Windows Server 2012

Change History

See Also