将数据摄取到Azure集群存储给出Kusto.Common.Svc.Exceptions.UnauthorizedOpe



——想要使用流方法添加插入数据到Azure存储集群。—已经生成了客户端,但是当尝试在集群表中插入新记录时,会给授权错误。注意,我已经添加了我的帐户访问表,也给权限摄取数据尽管除此之外,请让我知道是否有任何事情等待摄取数据或任何参考链接摄取数据在azure集群存储

var tempObject = new { starttime = startTime, endtime = endTime, trigger = rowKey, 
interval = "", site="",asset = asset,property = "",
aggregate = "", value = "",normal ="",
nvalue = "", svalue = "", meta = ""
};
var stringJson = JsonConvert.SerializeObject(tempObject);
var kustoUri = "https://{cluster}.{region}.kusto.windows.net";
var ingestUri = "https://ingest-{cluster}.{region}.kusto.windows.net";
string database = "abcd";
var kustoConnectionStringBuilder =
new KustoConnectionStringBuilder(ingestUri)
{
FederatedSecurity = true,
InitialCatalog = database,
Authority = "{tenantID}"
};

var ingestClient = KustoIngestFactory.CreateQueuedIngestClient(kustoConnectionStringBuilder);
var table = "TableName";
var tableMapping = "TableMapping";

var properties =
new KustoQueuedIngestionProperties(database, table)
{
Format = DataSourceFormat.multijson,
IngestionMapping = new IngestionMapping()
{
IngestionMappingReference = tableMapping
}
};
// convert string to stream
byte[] byteArray = Encoding.UTF8.GetBytes(stringJson);
//byte[] byteArray = Encoding.ASCII.GetBytes(contents);
MemoryStream stream = new MemoryStream(byteArray);
ingestClient.IngestFromStream(stream, properties);

下面的错误我得到@行ingestClient。IngestFromStream(流,属性);我使用以下引用将数据摄取到其中。

Kusto.Ingest.Exceptions.IngestionResourcesNotFoundException: 'No ingestion resources were returned from Kusto endpoint. Error: 'An exception was thrown while attempting to retrieve resources from endpoint : 'https://ingest-{cluster}.{region}.kusto.windows.net'. 'Forbidden (403-Forbidden): {
"error": {
"code": "Forbidden",
"message": "Caller is not authorized to perform this action",
"@type": "Kusto.Common.Svc.Exceptions.UnauthorizedOperationException",
"@message": "Principal 'msauser=username@gmail.com' is not authorized to perform operation 'Access the Kusto DM service for Ingest on any of the cluster's databases' on '[unspecified target]'.",
"@context": {
"timestamp": "2021-03-03T02:24:06.4434620Z",
"serviceAlias": "INGEST-RDDATAEXPLORERCLUSTER1",
"machineName": "KDataMana000000",
"processName": "Kusto.WinSvc.DM.Svc",
"processId": 11984,
"threadId": 4852,
"appDomainName": "Kusto.WinSvc.DM.Svc.exe",
"clientRequestId": "KI.KustoQueuedIngestClient.IngestFromStream.121db307-20b0-4940-b5aa-cdfaf8b1d4bc;5af7c92f-c57a-4d9f-bf6a-885bbcc4a52e;c7deb2bd-76bf-42b3-8eaf-84f4aac04986;1",
"activityId": "22fdfdd9-5dc2-46cd-a9b2-9e829cf907ab",
"subActivityId": "7916a2e6-daeb-4913-a2cd-77d82669320d",
"activityType": "P.WCF.Service.ExecuteControlCommandInternal..IAdminClientServiceCommunicationContract",
"parentActivityId": "8da57be2-5ab4-438b-88eb-211af02a36f1",
"activityStack": "(Activity stack: CRID=KI.KustoQueuedIngestClient.IngestFromStream.121db307-20b0-4940-b5aa-cdfaf8b1d4bc;5af7c92f-c57a-4d9f-bf6a-885bbcc4a52e;c7deb2bd-76bf-42b3-8eaf-84f4aac04986;1 ARID=22fdfdd9-5dc2-46cd-a9b2-9e829cf907ab > DN.Admin.Client.ExecuteControlCommand/8da57be2-5ab4-438b-88eb-211af02a36f1 > P.WCF.Service.ExecuteControlCommandInternal..IAdminClientServiceCommunicationContract/7916a2e6-daeb-4913-a2cd-77d82669320d)"
},
"@permanent": true
}
}. This normally represents a permanent error, and retrying is unlikely to help.
Error details:
DataSource='https://{cluster}.{region}.australiaeast.kusto.windows.net:443/v1/rest/mgmt',
DatabaseName='database name',
ClientRequestId='KI.KustoQueuedIngestClient.IngestFromStream.121db307-20b0-4940-b5aa-cdfaf8b1d4bc;5af7c92f-c57a-4d9f-bf6a-885bbcc4a52e;c7deb2bd-76bf-42b3-8eaf-84f4aac04986;1',
ActivityId='22fdfdd9-5dc2-46cd-a9b2-9e829cf907ab,
Timestamp='2021-03-03T02:24:04.6431925Z'.'''

该错误表明您没有权限将数据摄取到您试图摄取数据的特定表中。

请注意带有"用户"的人访问权限,不能将数据摄取到不是由该人员创建的表中。

请确保您的身份有"ingestor"对特定表或数据库的权限。您可以通过Azure门户或使用适用的命令来执行此操作。

@Avnera建议我正确的链接。虽然我想分享一个具体的命令来帮助我解决这个问题。

.add database Test admins ('msauser=username@gmail.com') 'User Name(gmail.com)'

最新更新