Azure存储SDK V1.3,以V2 => SetConfigurationSettingPublisher [英] Azure storage sdk v1.3 to v2 => SetConfigurationSettingPublisher

查看:139
本文介绍了Azure存储SDK V1.3,以V2 => SetConfigurationSettingPublisher的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你怎么可以转换这Azure存储V2.0,因为SetConfigurationSettingPublisher被删除了?

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

);

感谢

推荐答案

据<一href="http://blogs.msdn.com/b/windowsazurestorage/archive/2012/10/29/windows-azure-storage-client-library-2-0-breaking-changes-amp-migration-guide.aspx">Windows Azure存储客户端库2.0重大更改和放大器;迁移指南:

CloudStorageAccount.SetConfigurationSettingPublisher已被删除。的<一个相反成员href="http://msdn.microsoft.com/en-us/library/windowsazure/microsoft.windowsazure.storage.auth.storagecredentials.aspx">StorageCredentials现在是可变的,允许用户通过简单地通过所提供的UpdateKey方法变异与特定客户(S)相关的StorageCredentials实例来完成类似的场景在一个更加精简的方式。

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.

根据应用的需求,你可以简单地直接使用 CloudConfigurationManager.GetSetting()方法,如<一个描述href="http://www.thedailyparker.com/PermaLink,guid,be55f5e0-a041-4d14-aa7b-2966352ad724.aspx">Upgrading到Azure存储客户端2.0 :

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

如果您需要的角色实例运行时响应配置更改,您可以订阅<一个href="http://msdn.microsoft.com/en-us/library/windowsazure/gg432963.aspx"><$c$c>RoleEnvironment.Changing和<一href="http://msdn.microsoft.com/en-us/library/windowsazure/gg433023.aspx"><$c$c>RoleEnvironment.Changed事件在阅读的配置设置存储客户端库和处理更改的设置和描述<一个href="http://blogs.msdn.com/b/windowsazure/archive/2011/01/04/responding-to-role-topology-changes.aspx">Responding到角色的拓扑变化。

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.

这篇关于Azure存储SDK V1.3,以V2 =&GT; SetConfigurationSettingPublisher的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆