DEV Community

Kenichiro Nakamura
Kenichiro Nakamura

Posted on

Test KQL in ADX Emulator

Azure Data Explorer (ADX) emulator is a great way to test/learn KQL in local environment, which we don't even need Azure subscription. See here for detail.

Prerequisites

The emulator is packaged as docker image, and only supported in Windows container format.

Software:

  • Docker Client

Host OS:

  • Windows Server 2022
  • Windows Server 2019 Version 10.0.17763.2928 or newer
  • Windows 11

Hardware:

  • 2 GB of RAM minimum (recommend using 4+ GB)

The docker image is quite large, so I recommend using high speed network/Wi-Fi and make sure we have enough disk storage space.

image size

Create Environment

Install the emulator

Windows Server

docker run -e ACCEPT_EULA=Y -m 4G -d -p 8080:8080 -t mcr.microsoft.com/azuredataexplorer/kustainer:latest
Enter fullscreen mode Exit fullscreen mode

Windows 11

docker run -e ACCEPT_EULA=Y -m 4G -d -p 8080:8080 -t mcr.microsoft.com/azuredataexplorer/kustainer:windows11
Enter fullscreen mode Exit fullscreen mode

After container is pulled and started running, check the status.

curl -Method post -ContentType 'application/json' -Body '{"csl":".show cluster"}' http://localhost:8080/v1/rest/mgmt
Enter fullscreen mode Exit fullscreen mode

We can also use -v option to mount local folder to container image so that we can persist data.

Install Kusto Explorer and connect

1. Kusto Explorer is a GUI tool to use Kusto engine. Install from
https://aka.ms/ke

2. Once installed, click "Add connection". Expand "Advanced: Connection String" and enter Data Source=http://localhost:8080

Add connection

Create database and table

1. Run the following command to create database which is persited in specified path.

.create database <YourDatabaseName> persist (
  @"c:\kustodata\dbs\<YourDatabaseName>\md",
  @"c:\kustodata\dbs\<YourDatabaseName>\data"
  )
Enter fullscreen mode Exit fullscreen mode

Create database

2. Create table by using .create table command.

.create table MyIngestedSample(Name:string, Id:int)
Enter fullscreen mode Exit fullscreen mode

3. Insert (ingest) data into table. There are several ways to ingest but I use inline ingestion for now.

.ingest inline into table MyIngestedSample <| 
Chibi,1
May, 2
Kuon, 3
Enter fullscreen mode Exit fullscreen mode

Query data

Now we can run Kusto query almost same as ADX.

Query1

Query2

Query3

Next step

Now we have local ADX environment, which we can connect not only from Kusto Explorer but also CLI and SDK so that we can utilize it for development.

Top comments (0)