Edit

Share via


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

Prerequisites by method of cluster and database creation:

  • An Azure subscription. Create a free Azure account.
  • You can use Azure Cloud Shell to run the code in this article without having to install anything on your local environment.
  • 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.

Configure the CLI parameters

The following steps aren't required if you're running commands in Azure Cloud Shell. If you're running the CLI locally, follow these steps to set up the environment:

  1. Install extension to use the latest Kusto CLI version:

    Azure CLI
    az extension add -n kusto
    
  2. Run the following command to sign in to Azure:

    Azure CLI
    az login
    
  3. 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:

    Azure CLI
    az account set --subscription MyAzureSub
    
  4. 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:

    Azure CLI
    az group create --name testrg --location westus
    

Create an Azure Data Explorer cluster

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.

  1. Create your cluster by using the following command:

    Azure CLI
    az kusto cluster create --cluster-name azureclitest --sku name="Standard_E8ads_v5" tier="Standard" --resource-group testrg --location westus
    
    Setting Suggested value Field description
    name azureclitest The desired name of your cluster.
    sku Standard_E8ads_v5 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 westus The location where the cluster will be created.

    There are other optional parameters that you can use, such as the capacity of the cluster.

  2. Run the following command to check whether your cluster was successfully created:

    Azure CLI
    az kusto cluster show --cluster-name azureclitest --resource-group testrg
    
  3. Confirm the successful creation of the cluster by verifying the result contains provisioningState as Succeeded.

Create an Azure Data Explorer database

In this section, you'll create a database within the cluster created in the previous section.

  1. Create your database by using the following command:

    Azure CLI
    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=westus
    
    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 westus 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.
  2. Run the following command to see the database that you created:

    Azure CLI
    az kusto database show --database-name clidatabase --resource-group testrg --cluster-name azureclitest
    

Next step