Manage Azure HDInsight clusters by using the Azure CLI
Learn how to use the Azure CLI to manage Azure HDInsight clusters. The Azure CLI is the Microsoft command-line interface. You can use this cross-platform experience to manage 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, select Try it in the upper-right corner of the code block. Otherwise, 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, and 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 clusters
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. This action 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 number of worker nodes that you want 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
Related content
In this article, you learned how to perform different HDInsight cluster administrative tasks. To learn more, see the following articles: