Create an Azure Data Explorer cluster and database by using Azure CLI
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 ingest (load) data into a database so that you can run queries against it. In this article, you create a cluster and a database by using Azure CLI.
- An Azure subscription. Create a free Azure account.
Use Azure Cloud Shell
Azure hosts Azure Cloud Shell, an interactive shell environment that you can use through your browser. You can use either Bash or PowerShell with Cloud Shell to work with Azure services. You can use the Cloud Shell preinstalled commands to run the code in this article without having to install anything on your local environment.
To start Azure Cloud Shell:
|Select Try It in the upper-right corner of a code block. Selecting Try It doesn't automatically copy the code to Cloud Shell.|
|Go to https://shell.azure.com, or select the Launch Cloud Shell button to open Cloud Shell in your browser.|
|Select the Cloud Shell button on the menu bar at the upper right in the Azure portal.|
To run the code in this article in Azure Cloud Shell:
Start Cloud Shell.
Select the Copy button on a code block to copy the code.
Paste the code into the Cloud Shell session by selecting Ctrl+Shift+V on Windows and Linux or by selecting Cmd+Shift+V on macOS.
Select Enter to run the code.
- If you choose to install and use the Azure CLI locally, this article requires the Azure CLI version 2.0.4 or later. Run
az --versionto check your version. If you need to install or upgrade, see Install the Azure CLI.
Configure the CLI parameters
The following steps are not required if you're running commands in Azure Cloud Shell. If you're running the CLI locally, follow these steps to sign in to Azure and to set your current subscription:
Run the following command to sign in to Azure:
Set the subscription where you want your cluster to be created. Replace
MyAzureSubwith the name of the Azure subscription that you want to use:
az account set --subscription MyAzureSub
Install extension to use the latest Kusto CLI version:
az extension add -n kusto
Create the Azure Data Explorer 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 westus
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 westus The location where the cluster will be created.
There are additional 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
If the result contains
provisioningState with the
Succeeded value, then the cluster was successfully created.
Create the database in the Azure Data Explorer cluster
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=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.
Run the following command to see the database that you created:
az kusto database show --database-name clidatabase --resource-group testrg --cluster-name azureclitest
You now have a cluster and a database.
Clean up resources
If you plan to follow our other articles, keep the resources you created.
To clean up resources, delete the cluster. When you delete a cluster, it also deletes all the databases in it. Use the following command to delete your cluster:
az kusto cluster delete --cluster-name azureclitest --resource-group testrg