【问题标题】:Azure Diagnostics - runtime def vs. wadcfgAzure 诊断 - 运行时 def 与 wadcfg
【发布时间】:2014-01-29 19:45:41
【问题描述】:

我正在尝试了解在 Windows Azure 中配置诊断的各种方法。 到目前为止,我已经设置了 Azure 正确使用的 diagnostics.wadcfg,因为我在 wad-control-container 中的 Diagnostics 存储的 xml blob 中检索其内容(并且表以正确的刷新率更新)。

现在我想覆盖 cscfg 中的一些字段,以延长所有实例的日志传输周期,例如(无需更新每个 wad-control-container 文件,如果出现实例,该文件将被删除回收顺便说一句)。 所以在我的 WebRole.Run() 中,我从 RoleEnvironment.GetConfigurationSettingValue() 获取一个参数并尝试将其应用于当前配置;但我的问题是我从 DiagnosticMonitor.GetDefaultInitialConfiguration() 读取的值与我的 diagnostics.wadcfg 的内容不对应,并且在那里设置新值似乎没有任何效果。

谁能解释从 diagnostics.wadcfg 获取的内容与您可以在运行时设置的值之间的关系?

谢谢

【问题讨论】:

    标签: azure azure-diagnostics


    【解决方案1】:

    GetDefaultInitialConfiguration() 不会返回您当前的设置,因为它的名称表明它采用 default 配置。如果您需要采用现有的配置,则必须使用GetCurrentConfiguration 方法。

    但是,如果您只需要加快转移,您可以使用例如Cerebrata's Azure Diagnostics Manager 来快速启动您的角色的按需转移。

    您还可以将 Windows Azure 诊断管理 cmdlet 用于 powershell。查看this article

    希望这会有所帮助!

    【讨论】:

    • 确实该方法的名称应该敲响警钟...感谢您快速而彻底的回复!
    【解决方案2】:

    为了利用 wadcfg 文件中的值,可以使用以下代码访问当前的 DiagnosticsMonitorConfiguration:

    var cloudStorageAccount = CloudStorageAccount.Parse(
                RoleEnvironment.GetConfigurationSettingValue(WADStorageConnectionString));
    var roleInstanceDiagnosticManager = cloudStorageAccount.CreateRoleInstanceDiagnosticManager(
                RoleEnvironment.DeploymentId,
                RoleEnvironment.CurrentRoleInstance.Role.Name,
                RoleEnvironment.CurrentRoleInstance.Id);
    var dmc = roleInstanceDiagnosticManager.GetCurrentConfiguration();
    // Set different logging settings
    dmc.Logs....
    dmc.PerformanceCounters....
    // don't forget to update
    roleInstanceDiagnosticManager.SetCurrentConfiguration(dmc);
    

    【讨论】:

      【解决方案3】:

      Boris Lipshitz 的代码现在不起作用 (Breaking Changes in Windows Azure Diagnostics (SDK 2.0)):“DeploymentDiagnosticManager 构造函数现在接受到存储帐户的连接字符串,而不是 CloudStorageAccount 对象”。

      为 SDK 2.0+ 更新代码:

          var roleInstanceDiagnosticManager = new RoleInstanceDiagnosticManager(
      // Add StorageConnectionString to your role settings for this to work
                      CloudConfigurationManager.GetSetting("StorageConnectionString"), 
                      RoleEnvironment.DeploymentId,
                      RoleEnvironment.CurrentRoleInstance.Role.Name,
                      RoleEnvironment.CurrentRoleInstance.Id);
          var dmc = roleInstanceDiagnosticManager.GetCurrentConfiguration();
          // Set different logging settings
          dmc.Logs....
          dmc.PerformanceCounters....
          // don't forget to update
          roleInstanceDiagnosticManager.SetCurrentConfiguration(dmc)
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-08-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-08-27
        • 2013-07-18
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多