Eksportér (0) Udskriv
Udvid alt
EN
Dette indhold er ikke tilgængeligt på dit sprog, men her er den engelske version.

CloudStorageAccount.SetConfigurationSettingPublisher Method

Updated: September 24, 2013

[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)

'Brug
Dim configurationSettingPublisher As Action(Of String, Func(Of String, Boolean))

CloudStorageAccount.SetConfigurationSettingPublisher(configurationSettingPublisher)

public static void SetConfigurationSettingPublisher (
	Action<string,Func<string,bool>> configurationSettingPublisher
)

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, Windows Server 2008, Windows 8.1, Windows Server 2012 R2, Windows 8 and Windows Server 2012

 

Vis:
© 2014 Microsoft