Create an Azure Data Explorer cluster and database by using PowerShell
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 Powershell. You can run PowerShell cmdlets and scripts on Windows, Linux, or in Azure CLI with Az.Kusto to create and configure Azure Data Explorer clusters and databases.
This article has been updated to use the new Azure PowerShell Az module. You can still use the AzureRM module, which will continue to receive bug fixes until at least December 2020. To learn more about the new Az module and AzureRM compatibility, see Introducing the new Azure PowerShell Az module. For Az module installation instructions, see Install Azure PowerShell.
An Azure subscription. Create a Azure account.
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. To install or upgrade, see Install the Azure CLI.
For assignment of database reader or database administrator role, see assigning security roles.
The following steps are not required if you're running commands in Azure PowerShell. If you're running the CLI locally, follow steps 1 & 2 to sign in to Azure and to set your current subscription:
Run the following command to sign in to Azure:
Connect-AzAccount -EnvironmentName AzureChinaCloud
Set the subscription where you want your cluster to be created:
Set-AzContext -SubscriptionId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
When running Azure CLI locally or in the Azure PowerShell, you need to install the Az.Kusto module on your device:
Install-Module -Name Az.Kusto
Create the Azure Data Explorer cluster
Create your cluster by using the following command:
New-AzKustoCluster -ResourceGroupName testrg -Name mykustocluster -Location chinaeast2 -SkuTier Standard -SkuCapacity 2 -SkuName 'Standard_D11_v2'
Setting Suggested value Field description Name mykustocluster The desired name of your cluster. Sku D13_v2 The SKU that will be used for your cluster. ResourceGroupName testrg The resource group name 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:
Get-AzKustoCluster -Name mykustocluster -ResourceGroupName 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:
New-AzKustoDatabase -ResourceGroupName testrg -ClusterName mykustocluster -Name mykustodatabase -SoftDeletePeriod 3650:00:00:00 -HotCachePeriod 3650:00:00:00
Setting Suggested value Field description ClusterName mykustocluster The name of your cluster where the database will be created. Name mykustodatabase The name of your database. ResourceGroupName testrg The resource group name where the cluster will be created. SoftDeletePeriod 3650:00:00:00 The amount of time that data will be kept available to query. HotCachePeriod 3650:00:00:00 The amount of time that data will be kept in cache.
Run the following command to see the database that you created:
Get-AzKustoDatabase -ClusterName mykustocluster -ResourceGroupName testrg -Name mykustodatabase
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:
Remove-AzKustoCluster -ResourceGroupName testrg -Name mykustocluster