Azure OnDemand传输不会传输本地存储目录?

时间:2012-09-20 08:24:07

标签: azure-diagnostics

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

DiagHelper.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;
}

实际的冲洗/按需转移 管理/ 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)但是这里仍然是init代码

// ... 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>

1 个答案:

答案 0 :(得分:0)

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

  

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