azure-kusto-data
Advanced tools
Comparing version
@@ -38,20 +38,21 @@ const KustoClient = require("./index").Client; | ||
const appClient = new KustoClient(KustoConnectionBuilder.withAadApplicationKeyAuthentication( | ||
"https://toshetah.kusto.windows.net", "699b144f-07a1-480b-ad0d-9b918b4080d3", "pjErfNeJODILwINVwdJYL7B8hfY61UPvk2s6qeOHV08=", "72f988bf-86f1-41af-91ab-2d7cd011db47" | ||
)); | ||
// const appClient = new KustoClient(KustoConnectionBuilder.withAadApplicationKeyAuthentication( | ||
// "https://toshetah.kusto.windows.net", "699b144f-07a1-480b-ad0d-9b918b4080d3", "pjErfNeJODILwINVwdJYL7B8hfY61UPvk2s6qeOHV08=", "72f988bf-86f1-41af-91ab-2d7cd011db47" | ||
// )); | ||
const certClient = new KustoClient(KustoConnectionBuilder.withAadApplicationCertificateAuthentication( | ||
"https://toshetah.kusto.windows.net", "699b144f-07a1-480b-ad0d-9b918b4080d3", pem, "7614094C03E36E0601C1B613FF1F53B8135F5B69", "72f988bf-86f1-41af-91ab-2d7cd011db47" | ||
)); | ||
// const certClient = new KustoClient(KustoConnectionBuilder.withAadApplicationCertificateAuthentication( | ||
// "https://toshetah.kusto.windows.net", "699b144f-07a1-480b-ad0d-9b918b4080d3", pem, "7614094C03E36E0601C1B613FF1F53B8135F5B69", "72f988bf-86f1-41af-91ab-2d7cd011db47" | ||
// )); | ||
const deviceClient = new KustoClient(KustoConnectionBuilder.withAadDeviceAuthentication("https://toshetah.kusto.windows.net")); | ||
// const deviceClient = new KustoClient(KustoConnectionBuilder.withAadDeviceAuthentication("https://toshetah.kusto.windows.net")); | ||
// testQuery(userClient); | ||
testQuery(userClient); | ||
// testQuery(appClient); | ||
testQuery(certClient); | ||
// testQuery(certClient); | ||
// testQuery(deviceClient); | ||
function testQuery(client) { | ||
client.execute("daniel", "GithubEvent | limit 1", (err, results) => { | ||
let q = "print parse_json(\"{ 'X':1 }\"), dynamic(123),dynamic(\"123\"), \"123\", dynamic(\"foo\"), dynamic(null), dynamic({}), dynamic(\"{}\"), dynamic({ \"a\": 123 }), dynamic(''), dynamic({\"c\":[1,2,3], \"d\":{}}), dynamic([\"123\", dynamic(\"123\")])"; | ||
client.execute("daniel", q, (err, results) => { | ||
if (err) throw new Error(err); | ||
@@ -64,1 +65,14 @@ console.log(JSON.stringify(results)); | ||
// let clusterName = "Help"; // current | ||
// //let clusterName = "yifatskusto"; // new | ||
// let database = "Samples"; // current | ||
// //let database = "Database1"; // new | ||
// const kcs = KustoConnectionStringBuilder.withAadDeviceAuthentication(`https://${clusterName}.kusto.windows.net`); | ||
// const kustoClient = new KustoClient(kcs); | ||
// kustoClient.execute(database, "print parse_json(\"{ 'X':1 }\"), dynamic(123),dynamic(\"123\"), \"123\", dynamic(\"foo\"), dynamic(null), dynamic({}), dynamic(\"{}\"), dynamic({ \"a\": 123 }), dynamic(''), dynamic({\"c\":[1,2,3], \"d\":{}}), dynamic([\"123\", dynamic(\"123\")])", (err, results) => { | ||
// if (err) throw new Error(err); | ||
// console.log(JSON.stringify(results)); | ||
// console.log(results.primaryResults[0].toString()); | ||
// }); |
{ | ||
"name": "azure-kusto-data", | ||
"version": "0.1.0", | ||
"version": "0.1.4", | ||
"lockfileVersion": 1, | ||
@@ -5,0 +5,0 @@ "requires": true, |
{ | ||
"name": "azure-kusto-data", | ||
"version": "0.1.2", | ||
"version": "0.1.4", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -58,3 +58,11 @@ # Microsoft Azure Kusto Data Library for Node | ||
```javascript | ||
// will log the DEVICE token and url to use | ||
KustoConnectionStringBuilder.withAadDeviceAuthentication(`https://${clusterName}.kusto.windows.net`); | ||
// in case you want to do your own thing with the response, you can pass a callback | ||
// NOTICE: code will still block until device is authenticated | ||
KustoConnectionStringBuilder.withAadDeviceAuthentication(`https://${clusterName}.kusto.windows.net`, (toeknResponse) => { | ||
// your code, for example copy to clipboard or open url in browser | ||
console.log("Open " + tokenResponse.verificationUrl + " and use " + tokenResponse.userCode + " code to authorize."); | ||
}); | ||
``` | ||
@@ -61,0 +69,0 @@ |
@@ -52,3 +52,3 @@ const request = require("request"); | ||
"x-ms-client-version": `Kusto.Node.Client:${pkg.version}`, | ||
"x-ms-client-request-id": `KPC.execute;${uuidv4()}`, | ||
"x-ms-client-request-id": `KNC.execute;${uuidv4()}`, | ||
}; | ||
@@ -55,0 +55,0 @@ |
@@ -112,5 +112,8 @@ const KeywordMapping = Object.freeze({ | ||
static withAadDeviceAuthentication(connectionString) { | ||
return new KustoConnectionStringBuilder(connectionString); | ||
static withAadDeviceAuthentication(connectionString, authCallback) { | ||
const kcsb = new KustoConnectionStringBuilder(connectionString); | ||
kcsb.AuthorizationCallback = authCallback; | ||
return kcsb; | ||
} | ||
}; |
@@ -21,3 +21,3 @@ const moment = require("moment"); | ||
constructor(columns, row) { | ||
this.columns = columns.sort((a, b) => a.ordianl - b.ordianl); | ||
this.columns = columns.sort((a, b) => a.ordinal - b.ordinal); | ||
this.raw = row; | ||
@@ -60,7 +60,7 @@ | ||
class KustoResultColumn { | ||
constructor(columnObj, ordianl) { | ||
constructor(columnObj, ordinal) { | ||
this.name = columnObj.ColumnName; | ||
// TODO: should validate type? should coarse value to type? | ||
this.type = columnObj.ColumnType || columnObj.DateType; | ||
this.ordinal = ordianl; | ||
this.ordinal = ordinal; | ||
} | ||
@@ -67,0 +67,0 @@ } |
@@ -37,2 +37,3 @@ const { URL } = require("url"); | ||
this.clientId = "db662dc1-0cfe-4e1c-a843-19a68e65be58"; | ||
this.authCallback = kcsb.AuthorizationCallback; | ||
} | ||
@@ -69,3 +70,7 @@ } | ||
} else { | ||
console.log(tokenResponse.message); | ||
if (this.authCallback) { | ||
this.authCallback(tokenResponse); | ||
} else { | ||
console.log(tokenResponse.message); | ||
} | ||
@@ -72,0 +77,0 @@ return this.adalContext.acquireTokenWithDeviceCode(resource, this.clientId, tokenResponse, (err, tokenResponse) => { |
34593
5.8%716
2.73%72
12.5%