MicrosoftDocs / azure-docs

Open source documentation of Microsoft Azure
https://docs.microsoft.com/azure
Creative Commons Attribution 4.0 International
10.21k stars 21.36k forks source link

Automate task to delete and recreate HD Insight clusters #41935

Closed IronmanM closed 4 years ago

IronmanM commented 4 years ago

Hello Team,

Can we create the Script for Automate task to delete/Stop and recreate/start for HD Insight clusters / or Head node, please share documents/ Microsoft article

Thank you.

CHEEKATLAPRADEEP-MSFT-zz commented 4 years ago

@IronmanM You can create and delete Azure HDInsight clusters using Azure Automation.

HDInsight can be managed in Azure Automation by using the Azure HDInsight cmdlets that are available in the Azure PowerShell tools. Azure Automation has these cmdlets available out of the box, so that you can perform your HDInsight management tasks within the service. You can also pair these cmdlets in Azure Automation with the cmdlets for other Azure services, to automate complex tasks across Azure services and 3rd party systems.

You may refer this article which explains how to create and delete HDInsight clusters using Azure Automation.

Hope this helps.

CHEEKATLAPRADEEP-MSFT-zz commented 4 years ago

@IronmanM We will now proceed to close this thread. If there are further questions regarding this matter, please comment and we will gladly continue the discussion.

IronmanM commented 4 years ago

Hello @CHEEKATLAPRADEEP-MSFT ,

Thanks for your information,

I have tried the below script to create the Cluster with automation. $Conn = Get-AutomationConnection -Name AzureRunAsConnection Add-AzureRMAccount -ServicePrincipal -Tenant $Conn.TenantID -ApplicationId $Conn.ApplicationID -CertificateThumbprint $Conn.CertificateThumbprint $subscriptionID = Get-AutomationVariable –Name ‘0b3079f7-d19c-400e-8793-7b678538fc37’ Select-AzureRmSubscription –SubscriptionId $subscriptionID $resourceGroup = "marvel" $storageAccount = "ironman" $containerName = "spiderman" $storageAccountKey = (Get-AzureRmStorageAccountKey –Name $storageAccount –ResourceGroupName $resourceGroup)[0].value $clusterName = "marvelcluster1" $clusterCreds = Get-AutomationPSCredential –Name 'cluster-admin' $sshCreds = Get-AutomationPSCredential –Name 'ssh-user' $clusterType = "Hadoop" $clusterOS = "Linux" $clusterWorkerNodes = 2 $clusterNodeSize = "Standard_D1v2" $location = Get-AzureRmStorageAccount –StorageAccountName $storageAccount –ResourceGroupName $resourceGroup | %{$.Location} New-AzureRmHDInsightCluster –ClusterName $clusterName –ResourceGroupName $resourceGroup –Location $location –DefaultStorageAccountName "$storageAccount.blob.core.windows.net" –DefaultStorageAccountKey $storageAccountKey -DefaultStorageContainer $containerName –ClusterType $clusterType –OSType $clusterOS –Version "3.5" –HttpCredential $clusterCreds –SshCredential $sshCreds –ClusterSizeInNodes $clusterWorkerNodes –HeadNodeSize $clusterNodeSize –WorkerNodeSize $clusterNodeSize

i'm getting the error please look into this. Error :

Environments


{[AzureChinaCloud, AzureChinaCloud], [AzureCloud, AzureCloud], [AzureGermanCloud, AzureGermanCloud], [AzureUSGovernme... Get-AutomationVariable : A positional parameter cannot be found that accepts argument '�0b3079f7-d19c-400e-8793-7b678538fc37�'. At line:3 char:19

Set-AzureRmContext : A positional parameter cannot be found that accepts argument '$null'. At line:4 char:1

Get-AzureRmStorageAccountKey : A positional parameter cannot be found that accepts argument '�ResourceGroupName'. At line:8 char:23

Get-AutomationPSCredential : A positional parameter cannot be found that accepts argument 'cluster-admin'. At line:10 char:17

Get-AutomationPSCredential : A positional parameter cannot be found that accepts argument 'ssh-user'. At line:11 char:13

Get-AzureRmStorageAccount : A positional parameter cannot be found that accepts argument '�ResourceGroupName'. At line:16 char:13

New-AzureRmHDInsightCluster : A positional parameter cannot be found that accepts argument 'marvel'. At line:17 char:1

Thank you.

IronmanM commented 4 years ago

For below Command : $storageAccountKey = (Get-AzureRmStorageAccountKey –Name $storageAccount –ResourceGroupName $resourceGroup)[0].value

Getting this Error: Get-AzureRmStorageAccountKey : Cannot validate argument on parameter 'Name'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again. At line:1 char:58

IronmanM commented 4 years ago

Image link : https://imgur.com/6FeYcsW Error Image

CHEEKATLAPRADEEP-MSFT-zz commented 4 years ago

@IronmanM Since this issue is not related directly to the doc, I would recommend you to create a thread on the forums - MSDN. Once you post your issue on forums, it will have visibility across the community which is a better suited audience for such types of issues. Please create a Forum thread and post it's link here and tag me. I will now proceed to close this issue. Feel free to comment if you have any other queries.