c# - ADX: unable to ingest data via a control command using .NET sdk
问题描述
I defined a super-simple talbe:
.create table dummy (textfield: string)
I can properly execute an inline ingest command from Query panel:
.ingest inline into table dummy <| 'from query panel'
But I can't using .NET sdk:
using Kusto.Data;
using Kusto.Data.Common;
using Kusto.Data.Net.Client;
using System;
class Program
{
static void Main(string[] args)
{
var connection = new KustoConnectionStringBuilder("https://ingest-mycluster.westeurope.kusto.windows.net", "tracking")
.WithAadApplicationKeyAuthentication(
"MY_APPREG_ID",
"MY_APPREG_SECRET",
"MY_APPREG_TENANT");
var client = KustoClientFactory.CreateCslAdminProvider(connection);
client.ExecuteControlCommand(".ingest inline into table dummy <| 'from dot net'");
//var cmd = CslCommandGenerator.GenerateTableIngestPushCommand("dummy", true, "textfield\ndotnettest");
//client.ExecuteControlCommand(cmd);
Console.WriteLine("completed");
}
}
I've also tried with CslCommandGenerator
bust still always getting same exeception:
Kusto.Data.Exceptions.SyntaxException
HResult=0x80131500
Message=Syntax error: {
"error": {
"code": "BadRequest_SyntaxError",
"message": "Request is invalid and cannot be executed.",
"@type": "Kusto.Data.Exceptions.SyntaxException",
"@message": "Syntax error: . Query: '.ingest inline into table dummy <| 'from dot net''",
"@context": {
"timestamp": "2021-04-19T07:45:11.8614191Z",
"serviceAlias": "INGEST-ADXTESTCLUTER1",
"machineName": "KDataMana000000",
"processName": "Kusto.WinSvc.DM.Svc",
"processId": 1596,
"threadId": 3724,
"appDomainName": "Kusto.WinSvc.DM.Svc.exe",
"clientRequestId": "KD2RunCommand;a9e75e85-8ca7-43a0-b746-befcb92290a5",
"activityId": "5c3bfc38-c2dd-4985-80d0-ed29adea9158",
"subActivityId": "35a72a2f-129b-4691-8d06-4a1c6cf0384f",
"activityType": "P.WCF.Service.ExecuteControlCommandInternal..IAdminClientServiceCommunicationContract",
"parentActivityId": "ebe7b77f-ddc4-4bb6-ae71-72e9e50c7523",
"activityStack": "(Activity stack: CRID=KD2RunCommand;a9e75e85-8ca7-43a0-b746-befcb92290a5 ARID=5c3bfc38-c2dd-4985-80d0-ed29adea9158 > DN.Admin.Client.ExecuteControlCommand/ebe7b77f-ddc4-4bb6-ae71-72e9e50c7523 > P.WCF.Service.ExecuteControlCommandInternal..IAdminClientServiceCommunicationContract/35a72a2f-129b-4691-8d06-4a1c6cf0384f)"
},
"@permanent": true
}
}. Query: '.ingest inline into table dummy <| 'from dot net''
Source=Kusto.Data
StackTrace:
at Kusto.Cloud.Platform.Http.KustoHttpClient.<ThrowKustoExceptionFromResponseMessageAsync>d__4.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Kusto.Data.Net.Client.RestClient2.<MakeHttpRequestAsyncImpl>d__47.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at Kusto.Cloud.Platform.Utils.MonitoredActivity.<InvokeAsync>d__12`2.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Kusto.Cloud.Platform.Utils.MonitoredActivity.<InvokeAsync>d__12`2.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at Kusto.Data.Net.Client.RestClient2.<MakeHttpRequestAsync>d__45.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at Kusto.Data.Net.Client.RestClient2.<ExecuteControlCommandAsync>d__40.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Kusto.Cloud.Platform.Utils.ExtendedTask.ResultEx[TResult](Task`1 task)
at Kusto.Data.Net.Client.RestClient2.ExecuteControlCommand(String databaseName, String command, String addr, ClientRequestProperties properties)
at Kusto.Data.Net.Client.RestClient2.ExecuteControlCommand(String command, ClientRequestProperties properties)
at Program.Main(String[] args) in C:\Users\coder\source\repos\AdxInjectTest\Program.cs:line 18
This exception was originally thrown at this call stack:
[External Code]
Program.Main(string[]) in Program.cs
It reports a syntax error, but the command query is valid.
What am I missing?
Regards, Giacomo S. S.
解决方案
我正在使用摄取 URI,这是错误的。
正确的是:https://mycluster.westeurope.kusto.windows.net
推荐阅读
- html - 如何让 Android 软键盘覆盖我的网站?
- flutter - Flutter 主题 - primarySwatch 与 primaryColor
- excel - Excel 到 MySQL 在 Kettle/pdi 的三百列中用无或空替换所有“-”?
- javascript - 此 AJAX 调用代码中缺少什么?
- python - 如何正确建立用户组和数据库模型之间的连接?
- c - _WIN32, __linux__... 预处理器宏如何工作?
- turbo-c++ - 这是 TURBO C++ 中用于 2D 旋转的计算机图形代码。它编译得很好,但我无法运行它。我应该怎么办?
- c++ - QAxBase::dynamicCallHelper:对象不支持自动化
- thingsboard - SIM800A 向 Thingsboard 发送数据时出现问题
- express - 我可以在单个节点服务器上结合 Express 和 FTP 吗?