繁体   English   中英

从 Azure 函数应用程序摄取 Kusto 数据以 403 结束

[英]Kusto data ingestion from an Azure Function App ends with a 403

我尝试将数据从 azure 函数应用程序摄取到 ADX 数据库中。 我按照此处文章中的说明进行操作。

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

我做了什么:我创建了一个具有以下 API 权限的AAD 应用程序AAD 应用程序配置权限

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

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

.add table PressureRecords ingestors ('aadapp=;') 'theAADAppname'

.add table TemperatureRecords ingestors ('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);
            }

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

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

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

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

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

我目前的配置:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM