Manage Azure HDInsight clusters using Azure CLI

Learn how to use Azure CLI to manage Azure HDInsight clusters. The Azure command-line interface (CLI) is Microsoft's cross-platform command-line experience for managing Azure resources.

If you don't have an Azure subscription, create a free account before you begin.

Prerequisites

Connect to Azure

Sign in to your Azure subscription. If you plan to use Azure Cloud Shell then simply select Try it in the upper-right corner of the code block. Else, enter the command below:

az login

# If you have multiple subscriptions, set the one to use
# az account set --subscription "SUBSCRIPTIONID"

List clusters

Use az hdinsight list to list clusters. Edit the commands below by replacing RESOURCE_GROUP_NAME with the name of your resource group, then enter the commands:

# List all clusters in the current subscription
az hdinsight list

# List only cluster name and its resource group
az hdinsight list --query "[].{Cluster:name, ResourceGroup:resourceGroup}" --output table

# List all cluster for your resource group
az hdinsight list --resource-group RESOURCE_GROUP_NAME

# List all cluster names for your resource group
az hdinsight list --resource-group RESOURCE_GROUP_NAME --query "[].{clusterName:name}" --output table

Show cluster

Use az hdinsight show to show information for a specified cluster. Edit the command below by replacing RESOURCE_GROUP_NAME, and CLUSTER_NAME with the relevant information, then enter the command:

az hdinsight show --resource-group RESOURCE_GROUP_NAME --name CLUSTER_NAME

Delete clusters

Use az hdinsight delete to delete a specified cluster. Edit the command below by replacing RESOURCE_GROUP_NAME, and CLUSTER_NAME with the relevant information, then enter the command:

az hdinsight delete --resource-group RESOURCE_GROUP_NAME --name CLUSTER_NAME

You can also delete a cluster by deleting the resource group that contains the cluster. Note, this will delete all the resources in the group including the default storage account.

az group delete --name RESOURCE_GROUP_NAME

Scale clusters

Use az hdinsight resize to resize the specified HDInsight cluster to the specified size. Edit the command below by replacing RESOURCE_GROUP_NAME, and CLUSTER_NAME with the relevant information. Replace TARGET_INSTANCE_COUNT with the desired number of worker nodes for your cluster. For more information about scaling clusters, see Scale HDInsight clusters. Enter the command:

az hdinsight resize --resource-group RESOURCE_GROUP_NAME --name CLUSTER_NAME --target-instance-count TARGET_INSTANCE_COUNT

Next steps

In this article, you have learned how to perform different HDInsight cluster administrative tasks. To learn more, see the following articles: