我在将数据从 c# 代码保存到 Kusto Db 时遇到问题。我正在运行以下代码,但在 ExecuteControlCommand 中出现错误。任何人都可以帮助解决这个问题。我尝试了所有选项,但仍然没有运气
public static void LogMessage(string message)
{
var clusterName = "ABC";
var db = "Kusto";
var table = "Log";
var mappingName = "KustoJsonMapping";
// Set up table
var kcsbEngine =
new KustoConnectionStringBuilder($"https://KustoDB.kusto.windows.net");
using (var kustoAdminClient = KustoClientFactory.CreateCslAdminProvider(kcsbEngine))
{
var columns = new List<Tuple<string, string>>()
{
new Tuple<string, string>("logId", "System.String"),
new Tuple<string, string>("logDtm", "System.DateTime"),
new Tuple<string, string>("userName", "System.String"),
};
var command = CslCommandGenerator.GenerateTableCreateCommand(table, columns);
kustoAdminClient.ExecuteControlCommand(databaseName: db, command: command);
// Set up mapping
var columnMappings = new List<JsonColumnMapping>();
columnMappings.Add(new JsonColumnMapping()
{ ColumnName = "logId", JsonPath = "$.Id" });
columnMappings.Add(new JsonColumnMapping()
{ ColumnName = "logDtm", JsonPath = "$.Timestamp" });
columnMappings.Add(new JsonColumnMapping()
{ ColumnName = "userName", JsonPath = "$.Message" });
command = CslCommandGenerator.GenerateTableJsonMappingCreateCommand(
table, mappingName, columnMappings);
kustoAdminClient.ExecuteControlCommand(databaseName: db, command: command);
}
}
}