Kusto从Azure功能应用程序接收数据以403结尾

Kusto从Azure功能应用程序接收数据以403结尾,azure,function,azure-data-explorer,ingest,adx,Azure,Function,Azure Data Explorer,Ingest,Adx,我尝试将azure function应用程序中的数据摄取到ADX数据库中。我遵循了文章中的说明 区别在于,我想在表中插入数据。我遇到了403错误“Principal'aadapp=;'无权访问表” 我所做的: 我已创建具有以下API权限的AAD应用程序: 我通过Kusto Explorer配置了数据库: .add数据库myDB摄取器('aadapp=;')) “theAADAppname” .添加表格压力记录摄取器('aadapp=;'))'theAADAppname' .AddTableTe

我尝试将azure function应用程序中的数据摄取到ADX数据库中。我遵循了文章中的说明

区别在于,我想在表中插入数据。我遇到了403错误“Principal'aadapp=;'无权访问表”

我所做的: 我已创建具有以下API权限的AAD应用程序:

我通过Kusto Explorer配置了数据库:

.add数据库myDB摄取器('aadapp=;')) “theAADAppname”

.添加表格压力记录摄取器('aadapp=;'))'theAADAppname'

.AddTableTemperatureRecords摄取器('aadapp=;'))'theAADAppname'

我的代码:

 var kcsbDM = new KustoConnectionStringBuilder($"https://ingest-{serviceNameAndRegion}.kusto.windows.net:443/").WithAadApplicationKeyAuthentication(
            applicationClientId: "<my AD app Id>",
            applicationKey: "<my App Secret from Certificates & secrets>",
            authority: "<my tenant Id>");

        using (var ingestClient = KustoIngestFactory.CreateQueuedIngestClient(kcsbDM))
        {

            var ingestProps = new KustoQueuedIngestionProperties(databaseName, tableName);
            ingestProps.ReportLevel = IngestionReportLevel.FailuresAndSuccesses;
            ingestProps.ReportMethod = IngestionReportMethod.Queue;
            ingestProps.JSONMappingReference = mappingName;
            ingestProps.Format = DataSourceFormat.json;

            using (var memStream = new MemoryStream())
            using (var writer = new StreamWriter(memStream))
            {
                var messageString = JsonConvert.SerializeObject(myObject); // maps to the table / mapping 
                writer.WriteLine(messageString);
                writer.Flush();
                memStream.Seek(0, SeekOrigin.Begin);

                // Post ingestion message
                ingestClient.IngestFromStream(memStream, ingestProps, leaveOpen: true);
            }
var kcsbDM=new KustoConnectionStringBuilder($)https://ingest-{serviceNameAndRegion}.kusto.windows.net:443/”。带有应用程序密钥身份验证(
ApplicationClient:“”,
应用程序密钥:“”,
权限:);
使用(var ingestClient=KustoIngestFactory.CreateQueuedIngestClient(kcsbDM))
{
var ingestProps=新的KustoQueuedIngestionProperties(数据库名、表名);
InjectProps.ReportLevel=InjectionReportLevel.Failures和Successions;
InjectProps.ReportMethod=InjectionReportMethod.Queue;
ingestProps.JSONMappingReference=mappingName;
ingestProps.Format=DataSourceFormat.json;
使用(var memStream=new MemoryStream())
使用(var writer=newstreamwriter(memStream))
{
var messageString=JsonConvert.SerializeObject(myObject);//映射到表/映射
writer.WriteLine(messageString);
writer.Flush();
memStream.Seek(0,SeekOrigin.Begin);
//摄入后信息
ingestClient.IngestFromStream(memStream、ingestProps、leaveOpen:true);
}

问题在于,您在此摄取命令中使用的映射与现有表架构不匹配(它有其他列)。在这些情况下,Azure Data Explorer(Kusto)尝试添加在映射中找到的其他列。由于应用程序拥有的权限为“ingestor”,因此无法修改表结构,因此摄取失败

在您的特定情况下,您的表有一个列,该列写在特定的大小写中,在摄取映射中,同一列有不同的大小写(对于一个字符),因此它被视为一个新列


我们将研究在这种情况下提供更好的错误消息。

更新:该问题已在系统中修复,现在它已按预期工作

Avnera感谢您的提示,这可能是一个问题,因为实际翻译与双重翻译。在我的第一次尝试中,我在表中使用了双重翻译,并且有效。这不再可能了,看起来支持的数据类型已更改

我当前的配置:

.create table PressureRecords ( Timestamp:datetime, DeviceId:guid, Pressure:real )

.create-or-alter table PressureRecords ingestion json mapping "PressureRecords"
'['
'{"column":"TimeStamp","path":"$.DateTime","datatype":"datetime","transform":null},'
'{"column":"DeviceId","path":"$.DeviceId","datatype":"guid","transform":null},'
'{"column":"Pressure","path":"$.Pressure","datatype":"real","transform":null}'
']'

public class PressureRecord
{
    [JsonProperty(PropertyName = "Pressure")]
    public double Pressure { get; set; }
    [JsonProperty(PropertyName = "DateTime")]
    public DateTime DateTime { get; set; } = DateTime.Now;
    [JsonProperty(PropertyName = "DeviceId")]
    [Key]
    public Guid DeviceId { get; set; }
}

您所采取的步骤似乎还可以。如果没有其他上下文(例如,您收到的完整异常/错误消息),则无法调试此步骤如果您不想将这些包含在这个线程上,请考虑通过Azure PalalNO打开您的集群的支持票,这个错误与数据类型无关。问题是表中的“时间戳”在您的映射中显示为“时间戳”。因为列名是区分大小写的,所以我们认为“时间戳”是“时间戳”。是一个新列,我们尝试创建它,但是失败了,因为ingestor没有更改表架构的权限。很好,非常感谢,权限问题已经解决了。Unfort。我还有一个问题:我的代码示例中的messageString是“{”Pressure“:97914.0,“DateTime”:“2020-03-17T12:34:49.888901+00:00”,“DeviceId”:”f5693ab4-4550-4b4e-afc6-95a15c370078“}”,但每个操作都以“开关/案例中使用的Stream_NoDataToIngest:值“”无效”结束。如果字符串或字段顺序错误,是否是因为格式错误?