Manage Azure HDInsight clusters using Azure CLI
Learn how to use Azure CLI to manage Azure HDInsight clusters. The Azure 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
Azure CLI. If you haven't installed the Azure CLI, see Install the Azure CLI for steps.
An Apache Hadoop cluster on HDInsight. See Get Started with HDInsight on Linux.
Connect to Azure
Sign in to your Azure subscription. If you plan to use Azure Cloud Shell, then select Try it in the upper-right corner of the code block. Else, enter the following command:
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 following commands 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 following command 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 following command 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 deletes 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 following command by replacing RESOURCE_GROUP_NAME
, and CLUSTER_NAME
with the relevant information. Replace WORKERNODE_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 --workernode-count WORKERNODE_COUNT
Next steps
In this article, you've learned how to perform different HDInsight cluster administrative tasks. To learn more, see the following articles: