Tutorial: Create Azure HDInsight clusters with Azure Automation
Článok
With Azure Automation, you can create scripts that run in the cloud and manage Azure resources on-demand or based on a schedule. This article describes how to create PowerShell runbooks to create and delete Azure HDInsight clusters.
In this tutorial, you learn how to:
Install modules necessary for interacting with HDInsight.
Create and store credentials needed during cluster creation.
Create a new Automation runbook to create an HDInsight cluster.
If you don’t have an Azure subscription, create a free account before you begin.
Enter AzureRM.Profile in the box, and select Enter to search. Select the available search result.
On the AzureRM.profile screen, select Import. Select the checkbox to update Azure modules, and then select OK.
Return to the modules gallery. Under Shared Resources, select Modules gallery.
Enter HDInsight, and then select AzureRM.HDInsight.
On the AzureRM.HDInsight pane, select Import > OK.
Create credentials
Under Shared Resources, select Credentials.
Select Add a credential.
Enter the required information on the New Credential pane. This credential is used to store the cluster password. You use it to sign in to Ambari.
Property
Value
Name
cluster-password
User name
admin
Password
SECURE_PASSWORD
Confirm password
SECURE_PASSWORD
Select Create.
Repeat the same process for a new credential ssh-password with the username sshuser and a password of your choice. Select Create. This credential is used to store the Secure Shell protocol password for your cluster.
Create a runbook to create a cluster
Under Process Automation, select Runbooks.
Select Create a runbook.
On the Create a runbook pane, enter a name for the runbook, such as hdinsight-cluster-create. Select PowerShell from the Runbook type dropdown list.
Select Create.
Enter the following code on the Edit PowerShell Runbook screen, and then select Publish.
View the list of runbooks for your Automation account. Under Process Automation, select Runbooks.
Select hdinsight-cluster-create or the name that you used when you created your cluster creation runbook.
Select Start to run the runbook immediately. You can also schedule runbooks to run periodically. For more information, see Schedule a runbook in Automation.
Enter the required parameters for the script, and select OK. This step creates a new HDInsight cluster with the name that you specified in the CLUSTERNAME parameter.
Delete a cluster
Delete the cluster by selecting the hdinsight-cluster-delete runbook that you created. Select Start, enter the CLUSTERNAME parameter, and select OK.
Clean up resources
When your resource is no longer needed, delete the Automation account that you created to avoid unintended charges. Go to the Azure portal, select the resource group where you created the Automation account, select the Automation account, and then select Delete.