Azure崩溃转储未出现

时间:2011-04-20 08:44:36

标签: azure crash-dumps

下面的代码在Azure开发结构中运行时会产生崩溃转储,但在我将其部署到云时则不会。我有:

  • 关注Microsoft's instructions(见下文)
  • 通过上传blob在Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString中测试凭据。
  • 等待它崩溃(大约十次)。
  • 停止部署并等了半个小时。

但我仍然无法在存储帐户中找到任何内容。我使用VS 2010 Pro SP1瞄准.Net 4,并使用其内置的东西进行部署。我做错了什么?

public override void Run()
{
   throw new ApplicationException("bugger");
}

public override bool OnStart()
{
    ServicePointManager.DefaultConnectionLimit = 12;

    DiagnosticMonitorConfiguration config = DiagnosticMonitor.GetDefaultInitialConfiguration();
    string conn_str = RoleEnvironment.GetConfigurationSettingValue("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString");
    CloudStorageAccount account = CloudStorageAccount.Parse(conn_str);
    DiagnosticMonitor diagnosticMonitor = DiagnosticMonitor.Start(account, config);

    CrashDumps.EnableCollection(true);

    return base.OnStart();
}

这是我的配置:

<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="WindowsAzureProject1" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
  <WorkerRole name="WorkerRole1">
    <Imports>
      <Import moduleName="Diagnostics" />
    </Imports>
  </WorkerRole>
</ServiceDefinition>

<?xml version="1.0" encoding="utf-8"?>
<ServiceConfiguration serviceName="WindowsAzureProject1" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="1" osVersion="*">
  <Role name="WorkerRole1">
    <Instances count="1" />
    <ConfigurationSettings>
      <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="AccountName=XXX;AccountKey=XXX;DefaultEndpointsProtocol=https" />
    </ConfigurationSettings>
  </Role>
</ServiceConfiguration>

(我的真实项目 会产生崩溃转储,但我无法分析它们,这就是为什么我要尝试生成一个简化的示例。当它工作时我会看到它是否崩溃转储更好。)

编辑:部分解决方案是添加

config.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);

创建了wad-crash-dumps blob容器,但不幸的是它仍然是空的。另请参阅my question about what happens to diagnostic data when a role fails

3 个答案:

答案 0 :(得分:1)

在抛出异常之前添加了Thread.Sleep(60000)。我认为发生的事情就是这样:

  1. 抛出异常。
  2. 将崩溃转储保存到“DiagnosticStore”本地存储中,该存储可能配置为 cleanOnRoleRecycle设置为false。
  3. 虚拟机已回收,因为实例已经死亡。这将终止诊断管理器, 正在中止正在进行的任何上传。
  4. 启动诊断管理器的新实例。它开始上传旧转储。
  5. 转到1.

答案 1 :(得分:0)

我相信你错过了RoleInstanceDiagnosticManager。试着这样做:

DiagnosticMonitorConfiguration config = DiagnosticMonitor.GetDefaultInitialConfiguration();
    string conn_str = RoleEnvironment.GetConfigurationSettingValue("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString");
    CloudStorageAccount account = CloudStorageAccount.Parse(conn_str);
RoleInstanceDiagnosticManager roleInstanceDiagnosticManager = account.CreateRoleInstanceDiagnosticManager(RoleEnvironment.DeploymentId, RoleEnvironment.CurrentRoleInstance.Role.Name, RoleEnvironment.CurrentRoleInstance.Id);

    CrashDumps.EnableCollection(true);
config.Directories.DataSources.Add(AzureLocalStorageTraceListener.GetLogDirectory());
            config.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);
config.ConfigurationChangePollInterval = TimeSpan.FromMinutes(5);

            //set the configuration for use
            roleInstanceDiagnosticManager.SetCurrentConfiguration(config);  

RoleEnvironment.Changing += new EventHandler<RoleEnvironmentChangingEventArgs>(RoleEnvironment_Changing);

    return base.OnStart();

答案 2 :(得分:0)

您是否有可能未设置ScheduledTransferPeriod和LogLevelFilter?

TimeSpan tsLogPeriod = TimeSpan.FromMinutes(double.Parse(RoleEnvironment.GetConfigurationSettingValue("LogIntervalInMinutes")));
            DiagnosticMonitorConfiguration diagnosticMonitorConfiguration = DiagnosticMonitor.GetDefaultInitialConfiguration();

            diagnosticMonitorConfiguration.Logs.ScheduledTransferPeriod = tsLogPeriod;

            diagnosticMonitorConfiguration.Logs.ScheduledTransferLogLevelFilter = LogLevel.Verbose;

            DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", diagnosticMonitorConfiguration);

        }