Create an Azure Data Explorer cluster and database
Azure Data Explorer is a fast, fully managed data analytics service for real-time analysis on large volumes of data streaming from applications, websites, IoT devices, and more. To use Azure Data Explorer, you first create a cluster, and create one or more databases in that cluster. Then, you can ingest (load) data into a database and run queries against it.
In this article, you'll learn how to create a cluster and a database using either C#, Python, Go, the Azure CLI, PowerShell, or an Azure Resource Manager (ARM) template. To learn how to create a cluster and database using the Azure portal, see Quickstart: Create an Azure Data Explorer cluster and database.
For code samples based on previous SDK versions, see the archived article.
Prerequisites by method of cluster and database creation:
- An Azure subscription. Create a Azure account.
- If you choose to install and use the Azure CLI locally, follow the steps in Configure parameters. This article requires the Azure CLI version 2.0.4 or later. Run
az --version
to check your version. If you need to install or upgrade, see Install the Azure CLI.
If you're running the CLI locally, follow these steps to set up the environment:
Install extension to use the latest Kusto CLI version:
az extension add -n kusto
Run the following command to sign in to Azure:
az login
Set the subscription where you want your cluster to be created. Replace
MyAzureSub
with the name of the Azure subscription that you want to use:az account set --subscription MyAzureSub
Set the resource group where you want your cluster to be created. Replace
testrg
with the name of the resource group that you want to use:az group create --name testrg --location chinaeast2
This section guides you through the process of creating an Azure Data Explorer cluster. Choose the relevant tab for your preferred method to create the cluster.
Create your cluster by using the following command:
az kusto cluster create --cluster-name azureclitest --sku name="Standard_D13_v2" tier="Standard" --resource-group testrg --location chinaeast2
Setting Suggested value Field description name azureclitest The desired name of your cluster. sku Standard_D13_v2 The SKU that will be used for your cluster. Parameters: name - The SKU name. tier - The SKU tier. resource-group testrg The resource group name where the cluster will be created. location chinaeast2 The location where the cluster will be created. There are other optional parameters that you can use, such as the capacity of the cluster.
Run the following command to check whether your cluster was successfully created:
az kusto cluster show --cluster-name azureclitest --resource-group testrg
Confirm the successful creation of the cluster by verifying the result contains
provisioningState
asSucceeded
.
In this section, you'll create a database within the cluster created in the previous section.
Create your database by using the following command:
az kusto database create --cluster-name azureclitest --database-name clidatabase --resource-group testrg --read-write-database soft-delete-period=P365D hot-cache-period=P31D location=chinaeast2
Setting Suggested value Field description cluster-name azureclitest The name of your cluster where the database will be created. database-name clidatabase The name of your database. resource-group testrg The resource group name where the cluster will be created. read-write-database P365D P31D chinaeast2 The database type. Parameters: soft-delete-period - Signifies the amount of time the data will be kept available to query. See retention policy for more information. hot-cache-period - Signifies the amount of time the data will be kept in cache. See cache policy for more information. location -The location where the database will be created. Run the following command to see the database that you created:
az kusto database show --database-name clidatabase --resource-group testrg --cluster-name azureclitest