question

Emeka avatar image
Emeka asked

Error connecting PlayFab SDK and nodejs application

I have been trying to connect my nodejs application with azure playfab, then query the data using KQL. My code keep failing to run. Below is my code.

const KustoClient = require("azure-kusto-data").Client;
const KustoConnectionStringBuilder = require("azure-kusto-data").KustoConnectionStringBuilder;
const ClientRequestProperties = require("azure-kusto-data").ClientRequestProperties;
const { v4: uuidv4 } = require('uuid');

const clusterConectionString = "https://insights.playfab.com"; 
const database = "Mydatabase";
const table = 'events.all';
const appId = null;
const appKey = null;
const authorityId = null;

const kcs = KustoConnectionStringBuilder.withAadDeviceAuthentication(clusterConectionString, authorityId);
const kustoClient = new KustoClient(kcs);
start();

async function start() {
    try {
        const results = await kustoClient.execute(database, `['${table}'] | limit 1`);
       //console.log(JSON.stringify(results));
        //console.log(results.primaryResults[0].toString()); //._rows
    }
    catch (error) {
        console.log(error);
    }
}

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
JayZuo avatar image
JayZuo answered

To connect your NodeJs application to PlayFab Insights, please refer to Connecting Kusto C# SDK to Insights - PlayFab | Microsoft Docs. Although this doc is written for Kusto C# SDK, Node SDK should be similar.

So, please make sure you have Create an Azure Active Directory (AAD) application and connect it to your title database. And then set up "database", "appId", "appKey", "authorityId" correctly as per the doc.

2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Emeka avatar image Emeka commented ·

@Jay Zuo Thanks for your reply. I am also trying to set up "database", "appId", "appKey", "authorityId" but getting error.

0 Likes 0 ·
Sarah Zhang avatar image Sarah Zhang Emeka commented ·

Could you please also provide the detailed error messages for our reference?

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.