Reputation: 123
when i run this code it says KustoAuthenticationError: Failed to get cloud info for cluster https://clusterName.kusto.windows.net
The appId is the Application (client) ID, appKey is the value of the client secret and authorityId is the Directory (tenant) ID
I got this code from: https://github.com/Azure/azure-kusto-node/blob/master/packages/azure-kusto-ingest/example.js
code:
const IngestClient = require("azure-kusto-ingest").IngestClient;
const IngestStatusQueues = require("azure-kusto-ingest").IngestStatusQueues;
const IngestionProps = require("azure-kusto-ingest").IngestionProperties;
const KustoConnectionStringBuilder = require("azure-kusto-data").KustoConnectionStringBuilder;
const { DataFormat, JsonColumnMapping, IngestionMappingKind, CompressionType, ReportLevel, ReportMethod } = require("azure-kusto-ingest");
const { BlobDescriptor, StreamDescriptor } = require("azure-kusto-ingest").IngestionDescriptors;
const StreamingIngestClient = require("azure-kusto-ingest").StreamingIngestClient;
// const fs = require("fs");
const clusterName = "clusterName";
const authorityId = "authorityId";
const appId = "appId"
const appKey = "appKey"
var d = new Date();
var dateTimeNow = d.toJSON().slice(0,19).replace('T',':');
var data = {"Id" : "1314444525", "Temperature" : 32, "Battery" : 89, "Humidity" : 94, "Time" : dateTimeNow};
var s = require('stream');
var stream = new s.Readable();
stream.push(JSON.stringify(data));
stream.push(null);
// Streaming ingest client
const props2 = new IngestionProps({
database: "DBname",
table: "Tablename",
format: DataFormat.JSON,
ingestionMappingReference: "Pre-defined mapping name",
});
const streamingIngestClient = new StreamingIngestClient(
KustoConnectionStringBuilder.withAadApplicationKeyAuthentication(`https://${clusterName}.kusto.windows.net`, appId, appKey, authorityId),
props2
);
startStreamingIngestion();
async function startStreamingIngestion() {
try {
await streamingIngestClient.ingestFromStream(stream, props2);
console.log("Ingestion done");
await waitForStatus();
} catch (err) {
console.log(err);
}
}
async function waitForStatus(numberOFIngestions = 1) {
while ((await statusQueues.failure.isEmpty()) && (await statusQueues.success.isEmpty())) {
console.log("Waiting for status...");
await sleep(1000);
}
const failures = await statusQueues.failure.pop(numberOFIngestions);
for (let failure of failures) {
console.log('Failed: ${JSON.stringify(failure)}');
}
const successes = await statusQueues.success.pop(numberOFIngestions);
for (let success of successes) {
console.log('Succeeded: ${JSON.stringify(success)}');
}
}
function sleep(ms) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
}
Upvotes: 0
Views: 1136
Reputation: 603
This usually means you don’t have access to your ADX cluster’s endpoint. Verify whether your ADX cluster allows requests over the public network and that your Azure AD App doesn't have any outgoing network restrictions. In addition, make sure to grant 'ingestor' permission on your ADX database to your Azure AD App.
Upvotes: 1