[英]Kusto data ingestion from an Azure Function App ends with a 403
I try to ingest data from azure function app into a ADX database.我尝试将数据从 azure 函数应用程序摄取到 ADX 数据库中。 I followed the instruction found in the the article here .
我按照此处文章中的说明进行操作。
The difference is, I'd like to insert data into the table.不同之处在于,我想将数据插入表中。 I struggle with a 403 error "Principal 'aadapp=;'
我遇到了 403 错误“Principal 'aadapp=;' is not authorized to access table"
无权访问表”
What I did: I have created a AAD App with the following API permissions: AAD App configured permission我做了什么:我创建了一个具有以下 API 权限的AAD 应用程序: AAD 应用程序配置权限
I configured the database via Kusto Explorer:我通过 Kusto Explorer 配置了数据库:
.add database myDB ingestors ('aadapp=;') 'theAADAppname'
.add 数据库 myDB 摄取器 ('aadapp=;') 'theAADAppname'
.add table PressureRecords ingestors ('aadapp=;') 'theAADAppname'
.add table PressureRecords ingestors ('aadapp=;') 'theAADAppname'
.add table TemperatureRecords ingestors ('aadapp=;') 'theAADAppname'
.add table TemperatureRecords ingestors ('aadapp=;') 'theAADAppname'
My code:我的代码:
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);
}
The issue is that the mapping you are using in this ingestion command does not match the existing table schema (it has additional columns).问题是您在此摄取命令中使用的映射与现有表架构不匹配(它具有附加列)。 In these cases Azure Data Explorer (Kusto) attempts to add the additional columns it finds in the mappings.
在这些情况下,Azure 数据资源管理器 (Kusto) 会尝试添加它在映射中找到的其他列。 Since the permission that the app has is 'ingestor', it cannot modify the table structure and thus the ingestion fails.
由于应用程序拥有的权限是“摄取”,它无法修改表结构,因此摄取失败。
In your specific case, your table has a column that is written in a specific casing and in the ingestion mapping the same column has a different casing (for one character) so it is treated as a new column.在您的特定情况下,您的表有一个以特定大小写写入的列,并且在摄取映射中,同一列具有不同的大小写(对于一个字符),因此它被视为新列。
We will look into providing a better error message in this case.在这种情况下,我们将研究提供更好的错误消息。
Update : the issue is fixed in the system and now it works as expected.更新:该问题已在系统中修复,现在可以按预期工作。
Avnera thanks for your hint, potential it is an issue because of the Real vs double translation. Avnera 感谢您的提示,由于 Real vs 双重翻译,这可能是一个问题。 In one of my first try I used double in the table and that worked.
在我的第一次尝试中,我在表中使用了 double 并且奏效了。 That is not longer possible, looks the supported data types changed.
这不再可能,看起来支持的数据类型已更改。
My current configuration:我目前的配置:
.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.