0

我已将 Azure 诊断配置为传输本地存储(10MB,我的自定义日志和转储数据文件)。我定期传输目录-> blob 工作得很好。这是按需的,似乎不起作用。我手动创建了 blob 和队列,但仍然不行!进行按需传输的代码是

诊断助手.cs

public void StartOnDemandTransfer()
{
    OnDemandTransferOptions odtOptions = new OnDemandTransferOptions();
    odtOptions.From = DateTime.UtcNow.AddMinutes(-10.0);
    odtOptions.To = DateTime.UtcNow;
    //odtOptions.LogLevelFilter = LogLevel.Verbose;
    odtOptions.NotificationQueueName = "wad-on-demand-transfer";

    RoleInstanceDiagnosticManager ridm = getRoleInstanceDiagnosticManager();
    Guid odtTransferId = ridm.BeginOnDemandTransfer(DataBufferName.Directories, odtOptions);
}

public void EndTransfers()
{
    RoleInstanceDiagnosticManager ridm = getRoleInstanceDiagnosticManager();

    IDictionary<DataBufferName, OnDemandTransferInfo> activeTransfers = ridm.GetActiveTransfers();

    foreach (KeyValuePair<DataBufferName, OnDemandTransferInfo> activeTransfer in activeTransfers)
    {
        OnDemandTransferInfo odtInfo = activeTransfer.Value;
        Guid requestId = odtInfo.RequestId;
        ridm.EndOnDemandTransfer(requestId);
    }
}

public RoleInstanceDiagnosticManager getRoleInstanceDiagnosticManager()
{
    if (roleInstanceDiagnosticManager == null)
    {
        CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(
               RoleEnvironment.GetConfigurationSettingValue(wadConnectionString));
        roleInstanceDiagnosticManager = 
               cloudStorageAccount.CreateRoleInstanceDiagnosticManager(
                    RoleEnvironment.DeploymentId,
                    RoleEnvironment.CurrentRoleInstance.Role.Name,
                    RoleEnvironment.CurrentRoleInstance.Id);
    }
    return roleInstanceDiagnosticManager;
}

使用来自 admin/flushlogs.aspx.cs 的实际刷新/按需传输

protected void Button1_Click(object sender, EventArgs e)
{
    api.Diag.DiagHelper diag = new api.Diag.DiagHelper();
    diag.StartOnDemandTransfer();
    diag.EndTransfers();
}

问题:

有谁知道为什么 Windows Azure 诊断不传输我指定的本地存储?


额外细节:

我认为我已正确初始化 Azure 诊断,因为定期传输工作正常(必须手动创建 blob)但这里是初始化代码

// ... Other init stuff ...

// Custom logs
LocalResource localResource = RoleEnvironment.GetLocalResource("ApiLogFolder");
DirectoryConfiguration dirConfig = new DirectoryConfiguration();
dirConfig.Container = "apilog-blob";
dirConfig.DirectoryQuotaInMB = localResource.MaximumSizeInMegabytes;
dirConfig.Path = localResource.RootPath;
config.Directories.DataSources.Add(dirConfig);
config.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(10.0);


roleInstanceDiagnosticManager.SetCurrentConfiguration(config); 

我在 ServiceDefinition.csdef 中定义了本地存储,如下所示

<LocalResources>
  <LocalStorage name="Microsoft.WindowsAzure.Plugins.Caching.FileStore" sizeInMB="1000" cleanOnRoleRecycle="false" />
  <LocalStorage name="ApiLogFolder" cleanOnRoleRecycle="false" sizeInMB="10" />
</LocalResources>
4

1 回答 1

0

这可能是因为您在调用 BeginOnDemandTransfer 之后立即调用 EndOnDemandTransfer。基于这些方法的命名,很容易理解为什么您会认为 EndOnDemandTransfer 会阻塞直到传输完成,或者类似的事情。但根据 MSDN(http://msdn.microsoft.com/en-us/library/windowsazure/microsoft.windowsazure.diagnostics.management.roleinstancediagnosticmanager.endondemandtransfer.aspx):

EndOnDemandTransfer 方法停止正在进行的诊断数据传输。

于 2013-02-15T13:05:31.917 回答