IngestFromStreamAsync方法不起作用

我设法使用以下代码成功提取数据

var kcsbDM =新的kustoConnectionStringBuilder(“ https://test123.southeastasia.kusto.windows.net”,“ testdb”)。WithAadApplicationTokenAuthentication(acquireTokenTask.accessToken);

使用(var ingestClient = kustoIngestFactory.CreateDirectIngestClient(kcsbDM))
{

var ingestProps = new kustoQueuedIngestionProperties("testdb","TraceLog");
ingestProps.ReportLevel = IngestionReportLevel.FailuresOnly;
ingestProps.ReportMethod = IngestionReportMethod.Queue;
ingestProps.Format = DataSourceFormat.json;

//generate datastream and columnmapping

ingestProps.Ingestionmapping = new Ingestionmapping() { Ingestionmappings = columnmappings };
var ingestionResult = ingestClient.IngestFromStream(memStream,ingestProps);

}

当我尝试使用QueuedClient和IngestFromStreamAsync时,代码已成功执行,但即使30分钟后也没有任何数据被摄取到数据库中

var kcsbDM =新的kustoConnectionStringBuilder(“ https://ingest-test123.southeastasia.kusto.windows.net”,“ testdb”)。WithAadApplicationTokenAuthentication(acquireTokenTask.accessToken);

使用(var ingestClient = kustoIngestFactory.CreateQueuedIngestClient(kcsbDM))
{

var ingestProps = new kustoQueuedIngestionProperties("testdb","TraceLog");
ingestProps.ReportLevel = IngestionReportLevel.FailuresOnly;
ingestProps.ReportMethod = IngestionReportMethod.Queue;
ingestProps.Format = DataSourceFormat.json;

//generate datastream and columnmapping

ingestProps.Ingestionmapping = new Ingestionmapping() { Ingestionmappings = columnmappings };
var ingestionResult = ingestClient.IngestFromStreamAsync(memStream,ingestProps);

}

iCMS 回答:IngestFromStreamAsync方法不起作用

尝试在“ https://test123.southeastasia.kusto.windows.net”端点上运行.show提取失败,查看是否存在提取错误。 另外,您设置了队列报告方法,可以通过从队列中读取来获得详细的结果。

ingestProps.ReportLevel = IngestionReportLevel.FailuresOnly;
ingestProps.ReportMethod = IngestionReportMethod.Queue;

(在您使用KustoQueuedIngestionProperties的第一个示例中,您应该使用KustoIngestionPropertiesKustoQueuedIngestionProperties具有其他属性,摄取客户端会忽略这些属性,例如ReportLevel和ReportMethod)>

,

可以将行更改为: var ingestionResult =等待ingestClient.IngestFromStreamAsync(memStream,ingestProps);

还请注意,在实际提取数据之前,排队提取的批处理阶段最多需要5分钟: https://docs.microsoft.com/en-us/azure/data-explorer/kusto/management/batchingpolicy https://docs.microsoft.com/en-us/azure/data-explorer/kusto/management/batching-policy

,

我终于找到了原因,需要在表中启用流摄取:

.alter table TraceLog policy streamingingestion enable

有关详细信息,请参见the Azure documentation

,

仅在以下情况下才需要启用流式传输策略

  • 在集群(azure门户)中打开流摄取
  • 代码正在使用CreateManagedStreamingIngestClient

ManagedStreamingIngestClient首先将尝试流式提取数据,如果几次失败,则将使用QueuedClient

如果接收的数据较小(小于4MB),则建议使用此客户端。

如果使用QueuedClient,则可以尝试

.show commands-and-queries | | where StartedOn > ago(20m) and Text contains "{YourTableName}" and CommandType =="DataIngestPull" 

这可以给您执行的命令;但是它可能会延迟5分钟以上

最后,您可以与您使用的任何客户端一起检查状态,

            StreamDescription description = new StreamDescription
            {
                SourceId = Guid.NewGuid(),Stream = dataStream
            };

然后您就有了源ID

通过调用

进行逗趣:

var checker = await client.IngestFromStreamAsync(description,ingestProps);

之后,致电

var statusCheck = checker.GetIngestionStatusBySourceId(description.sourceId.Value);

您可以找出此提取作业的状态。最好将其包装在单独的线程中,因此,例如,您可以继续检查一次。

本文链接:https://www.f2er.com/2212552.html

大家都在问