簡體   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