How do I use Kusto client to create table?

New Contributor

I am trying to automate provisioning of Kusto cluster. So far I have terraform to create the cluster, create the database. I have yet to find a way to create a table. 


I went down the path of using python but I ran into an issue (see further below) so switched to java. With Java I am getting an error with the query syntax. Can someone point me to the correct syntax that I should be using to create tables with the client?


Java Error


Caused by: BadRequest_SyntaxError: Request is invalid and cannot be executed.
Syntax error: Query could not be parsed: . Query: '.create table FlowState ( id:string, flow:string, flowRunId:string )'



Python Error (Note: I have 'adal' installed.)


Traceback (most recent call last):

  File "", line 1, in <module>

    from import KustoServiceError

  File "/.../python3.6/site-packages/azure_kusto_data-0.0.44-py3.6.egg/azure/kusto/data/", line 3, in <module>

    from .request import KustoClient, KustoConnectionStringBuilder, ClientRequestProperties

  File "/.../python3.6/site-packages/azure_kusto_data-0.0.44-py3.6.egg/azure/kusto/data/", line 17, in <module>

    from .security import _AadHelper

  File "/.../python3.6/site-packages/azure_kusto_data-0.0.44-py3.6.egg/azure/kusto/data/", line 10, in <module>

    from adal import AuthenticationContext, AdalError

ModuleNotFoundError: No module named 'adal'


2 Replies

@kusto345 , The error does suggest that you are missing adal. 
It may be because you are working on a different environment where adal is missing (virtualenv, conda, etc..) or that you have an old version installed.

Could you kindly paste the output of pip freeze, and try and import adal in python REPL?

@Daniel Dubovski thanks for responding and the pointer, apologies that it took me so long to respond.


I cleaned up my env and recreated it. I seem to have made progress but still unable to use the client sdk to create a table


'message': 'Caller is not authorized to perform this action', '@type': 'Kusto.DataNode.Exceptions.UnauthorizedDatabaseAccessException', '@message': "Principal 'aadapp=<sp>;<tenant-id>' is not authorized to access database '<database-name>'."


So I turned to azure cli to grant the role of "AllDatabasesAdmin" to my service principal. I however do not see any of the roles for ADX. As a result when I try to grant my sp access to the database it just does not find the role. I picked a role from the portal, there are two "AllDatabasesAdmin" and "AllDatabasesViewer"


az role assignment create --assignee <sp> --scope <resource-path-to-database> --role AllDatabasesAdmin.


I get the following exception 

Role 'AllDatabasesAdmin' doesn't exist.