> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreflux.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Azure Data Explorer and Fabric Eventhouse

> Client-mode REST API connector for Azure Data Explorer (Kusto) and Fabric Eventhouse — KQL query, management commands, and streaming JSON ingest from MQTT

Technical Preview

## Overview

A client-mode connector for a **curated** slice of the [Kusto REST API](https://learn.microsoft.com/en-us/kusto/api/rest/?view=azure-data-explorer) used by **Azure Data Explorer** and **Microsoft Fabric Eventhouse**:

| Catalog connector event | Entity / path | Notes |
| - | - | - |
| POST query (KQL) | `POST /v1/rest/query` | Body `{"db","csl"}` — also `POST /v2/rest/query` |
| (supporting) GET query | `GET /v1/rest/query?db=&csl=` | Query-string form |
| POST mgmt | `POST /v1/rest/mgmt` | Management commands (`.show …`) |
| POST ingest JSON | `POST /v1/rest/ingest/{db}/{table}?streamFormat=JSON&mappingName=` | **Streaming** ingest on the **engine** Cluster URI |

Default `BASE_ADDRESS` is `https://YOUR_CLUSTER.YOUR_REGION.kusto.windows.net` (no trailing slash). For Fabric, use the Eventhouse **Query URI**. Topics use `data/azure-data-explorer/<verb>`.

See the base guide: [REST API Connectors](/latest/lot-language/routes/rest-api-routes).

> [!NOTE]
>
> **Auth:** `Authorization: Bearer &lt;entra_access_token&gt;`. Prefer Hub secrets (`GET SECRET "ADX_ACCESS_TOKEN"` or `"KUSTO_ACCESS_TOKEN"`). Token resource is typically `https://api.kusto.windows.net` or the cluster URI.

> [!NOTE]
>
> **Streaming vs queued ingest:** `/v1/rest/ingest/...` streaming ingest uses the **engine** host (same as query). The portal Data ingestion URI (`ingest-*`) is for queued/bulk pipelines and is not the `BASE_ADDRESS` for this template.

> [!NOTE]
>
> Factory live smoke is **blocked** until an Entra Bearer token + cluster/Eventhouse URI are available. Public `help.kusto.windows.net` returns **401** without auth (host reachable).

## Basic Syntax

```lot wrap theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
# Coreflux REST_API template — Azure Data Explorer / Fabric Eventhouse
# Auth: Authorization: Bearer {value.json.access_token}
# BASE_ADDRESS: https://YOUR_CLUSTER.YOUR_REGION.kusto.windows.net

DEFINE ROUTE AzureDataExplorerRestApi WITH TYPE REST_API
    ADD REST_API_CONFIG
        WITH BASE_ADDRESS "https://YOUR_CLUSTER.YOUR_REGION.kusto.windows.net"
        WITH ENABLE_CLIENT "true"
        WITH USE_SSL "true"
        WITH REQUEST_TIMEOUT '60'
        WITH DEFAULT_CONTENT_TYPE "application/json"
    ADD EVENT PostQuery
        WITH SOURCE_TOPIC "data/azure-data-explorer/query"
        WITH DESTINATION_TOPIC "data/azure-data-explorer/query/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/v1/rest/query"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json; charset=utf-8"
            ADD "Authorization" "Bearer {value.json.access_token}"
        WITH BODY "{payload}"
    ADD EVENT PostMgmt
        WITH SOURCE_TOPIC "data/azure-data-explorer/mgmt"
        WITH DESTINATION_TOPIC "data/azure-data-explorer/mgmt/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/v1/rest/mgmt"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json; charset=utf-8"
            ADD "Authorization" "Bearer {value.json.access_token}"
        WITH BODY "{payload}"
    ADD EVENT PostIngestJson
        WITH SOURCE_TOPIC "data/azure-data-explorer/ingest"
        WITH DESTINATION_TOPIC "data/azure-data-explorer/ingest/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/v1/rest/ingest/{value.json.database}/{value.json.table}?streamFormat=JSON&mappingName={value.json.mapping_name}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json; charset=utf-8"
            ADD "Authorization" "Bearer {value.json.access_token}"
        WITH BODY "{payload}"
```

Full template (query v2, GET query, client-request-id headers): see the package `AzureDataExplorerRestApi.lot` under the broker templates tree after you push `feat/rest-api-route-azure-data-explorer-and-fabric-eventhouse`.

## Auth and placeholders

| Placeholder | Meaning |
| - | - |
| `{value.json.access_token}` | Entra ID access token → `Authorization: Bearer …` |
| `{value.json.database}` / `{value.json.table}` | Ingest path segments |
| `{value.json.mapping_name}` | Pre-created ingestion mapping (required for JSON) |
| `{value.json.db}` / `{value.json.csl}` | GET query query-string params |
| `{value.json.client_request_id}` | Optional `x-ms-client-request-id` |
| `{payload}` | JSON body for query/mgmt, or raw JSON record(s) for ingest |

## Template reference

Generated from the shipped broker template `azure-data-explorer-and-fabric-eventhouse` (`-routeCode AZURE_DATA_EXPLORER_AND_FABRIC_EVENTHOUSE`). It lists every event the template defines.

### Auth

Authorization: Bearer \{value.json.access\_token} (Microsoft Entra ID OAuth 2.0). Prefer GET SECRET ADX\_ACCESS\_TOKEN or KUSTO\_ACCESS\_TOKEN. Token resource typically [https://api.kusto.windows.net](https://api.kusto.windows.net) or the cluster URI. Never commit real credentials.

Auth headers used by the template: `Authorization: Bearer {value.json.access_token}`.

### Template parameters

| Placeholder | Type | Description | Required |
| - | - | - | - |
| `RouteName` | string | Name of the Azure Data Explorer and Fabric Eventhouse connector | no |
| `BaseUrl` | string | Azure Data Explorer and Fabric Eventhouse base URL without trailing slash (e.g. [https://YOUR\_CLUSTER.YOUR\_REGION.kusto.windows.net](https://YOUR_CLUSTER.YOUR_REGION.kusto.windows.net)) | yes |

`BASE_ADDRESS` default: `https://YOUR_CLUSTER.YOUR_REGION.kusto.windows.net`.

### Events

| Event | Method | Endpoint | Request topic | Response topic | Payload fields |
| - | - | - | - | - | - |
| `PostQuery` | POST | `/v1/rest/query` | `data/azure-data-explorer/query` | `data/azure-data-explorer/query/response` | `access_token`, `body`, `client_request_id` |
| `PostQueryV2` | POST | `/v2/rest/query` | `data/azure-data-explorer/query-v2` | `data/azure-data-explorer/query-v2/response` | `access_token`, `body`, `client_request_id` |
| `GetQuery` | GET | `/v1/rest/query?db={value.json.db}&csl={value.json.csl}` | `data/azure-data-explorer/query-get` | `data/azure-data-explorer/query-get/response` | `access_token`, `csl`, `db` |
| `PostMgmt` | POST | `/v1/rest/mgmt` | `data/azure-data-explorer/mgmt` | `data/azure-data-explorer/mgmt/response` | `access_token`, `body`, `client_request_id` |
| `PostIngestJson` | POST | `/v1/rest/ingest/{value.json.database}/{value.json.table}?streamFormat=JSON&mappingName={value.json.mapping_name}` | `data/azure-data-explorer/ingest` | `data/azure-data-explorer/ingest/response` | `access_token`, `body`, `client_request_id`, `database`, `mapping_name`, `table` |

### Deploy

Get the template card (JSON with `template` and `metadata`) from the broker, then deploy the connector:

```bash theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
mosquitto_pub -t '$SYS/Coreflux/Command' -m "-routeCode AZURE_DATA_EXPLORER_AND_FABRIC_EVENTHOUSE"
```

The deployable connector from the REST API app, with `BASE_ADDRESS` already filled in:

```lot theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
DEFINE ROUTE AzureDataExplorerRestApi WITH TYPE REST_API
    ADD REST_API_CONFIG
        WITH BASE_ADDRESS "https://YOUR_CLUSTER.YOUR_REGION.kusto.windows.net"
        WITH ENABLE_CLIENT "true"
        WITH USE_SSL "true"
        WITH REQUEST_TIMEOUT '60'
        WITH DEFAULT_CONTENT_TYPE "application/json"
    ADD EVENT PostQuery
        WITH SOURCE_TOPIC "data/azure-data-explorer/query"
        WITH DESTINATION_TOPIC "data/azure-data-explorer/query/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/v1/rest/query"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json; charset=utf-8"
            ADD "Authorization" "Bearer {value.json.access_token}"
            ADD "x-ms-app" "Coreflux"
            ADD "x-ms-client-request-id" "{value.json.client_request_id}"
        WITH BODY "{value.json.body}"
    ADD EVENT PostQueryV2
        WITH SOURCE_TOPIC "data/azure-data-explorer/query-v2"
        WITH DESTINATION_TOPIC "data/azure-data-explorer/query-v2/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/v2/rest/query"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json; charset=utf-8"
            ADD "Authorization" "Bearer {value.json.access_token}"
            ADD "x-ms-app" "Coreflux"
            ADD "x-ms-client-request-id" "{value.json.client_request_id}"
        WITH BODY "{value.json.body}"
    ADD EVENT GetQuery
        WITH SOURCE_TOPIC "data/azure-data-explorer/query-get"
        WITH DESTINATION_TOPIC "data/azure-data-explorer/query-get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/v1/rest/query?db={value.json.db}&csl={value.json.csl}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "Bearer {value.json.access_token}"
            ADD "x-ms-app" "Coreflux"
    ADD EVENT PostMgmt
        WITH SOURCE_TOPIC "data/azure-data-explorer/mgmt"
        WITH DESTINATION_TOPIC "data/azure-data-explorer/mgmt/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/v1/rest/mgmt"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json; charset=utf-8"
            ADD "Authorization" "Bearer {value.json.access_token}"
            ADD "x-ms-app" "Coreflux"
            ADD "x-ms-client-request-id" "{value.json.client_request_id}"
        WITH BODY "{value.json.body}"
    ADD EVENT PostIngestJson
        WITH SOURCE_TOPIC "data/azure-data-explorer/ingest"
        WITH DESTINATION_TOPIC "data/azure-data-explorer/ingest/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/v1/rest/ingest/{value.json.database}/{value.json.table}?streamFormat=JSON&mappingName={value.json.mapping_name}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json; charset=utf-8"
            ADD "Authorization" "Bearer {value.json.access_token}"
            ADD "x-ms-app" "Coreflux"
            ADD "x-ms-client-request-id" "{value.json.client_request_id}"
        WITH BODY "{value.json.body}"
```

Deploy it with `-addRoute` (do not include `ADD METADATA`).

### Usage example

Call `PostQuery` by publishing a JSON payload to its request topic, and read the reply on the response topic:

```bash theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
mosquitto_sub -t 'data/azure-data-explorer/query/response' &
mosquitto_pub -t 'data/azure-data-explorer/query' -m '{"access_token": "<access_token>", "body": {}, "client_request_id": "<client_request_id>"}'
```

## Related

* [REST API Connectors](/latest/lot-language/routes/rest-api-routes)
* [REST API Apps catalog](/latest/lot-language/routes/rest-api-apps)
* [Kusto REST API overview](https://learn.microsoft.com/en-us/kusto/api/rest/?view=azure-data-explorer)
* [Query / management request](https://learn.microsoft.com/en-us/kusto/api/rest/request)
* [Streaming ingestion](https://learn.microsoft.com/en-us/kusto/api/rest/streaming-ingest)
* [Authentication](https://learn.microsoft.com/en-us/kusto/api/rest/authentication)
* [Fabric Kusto REST](https://learn.microsoft.com/en-us/kusto/api/rest/?view=microsoft-fabric)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.