azure - 使用powershell创建HDCluster

标签 azure azure-hdinsight azure-powershell

我正在尝试使用 powershell 创建集群。这是我正在执行的脚本:

$containerName = "hdfiles"
$location = "Southeast Asia"
$clusterNodes = 2
$userName = "HDUser"

#Generate random password
$rand = New-Object System.Random
$pass = ""
$pass = $pass + [char]$rand.next(97,121) #lower case
$pass = $pass + [char]$rand.next(48,57) #number
$pass = $pass + [char]$rand.next(65,90) #upper case
$pass = $pass + [char]$rand.next(58,62) #special character
1..6 | ForEach { $pass = $pass + [char]$rand.next(97,121) } #6 lower-case characters
$password = ConvertTo-SecureString $pass -AsPlainText -Force

# generate unique random cluster and storage account names
do
{
  $clusterName = "hd"
  1..6 | ForEach { $clusterName = $clusterName + [char]$rand.next(48,57) }
  $storageAccountName = $clusterName + "store"
}
while ((Test-AzureName -Name $storageAccountName -Storage) -and (Test-AzureName -Name $clusterName -Service))

# Create a storage account
Write-Host "Creating storage account..."
New-AzureStorageAccount -StorageAccountName $storageAccountName -Location $location

# Create a Blob storage container
Write-Host "Creating container..."
$storageAccountKey = Get-AzureStorageKey $storageAccountName | %{ $_.Primary }
$destContext = New-AzureStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storageAccountKey
New-AzureStorageContainer -Name $containerName -Context $destContext

# Create a cluster
Write-Host "Creating HDInsight cluster..."
$credential = New-Object System.Management.Automation.PSCredential ($userName, $password)
New-AzureHDInsightCluster -Name $clusterName -Location $location -DefaultStorageAccountName "$storageAccountName.blob.core.windows.net" -DefaultStorageAccountKey $storageAccountKey -DefaultStorageContainerName $containerName -ClusterSizeInNodes $clusterNodes -Credential $credential -Version 3.2

但是在最后一行我遇到了异常:

New-AzureHDInsightCluster : Validating connection to 'hd662173store.blob.core.windows.net' failed. Inner exception:Could not load file or assembly 'Microsoft.WindowsAzure.Storage, Version=3.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
At D:\ProgrammingWorkspace\Edx\Processing BigData with HDInsight\HDILabs\Lab02A\Provision HDInsight.ps1:38 char:1 + New-AzureHDInsightCluster -Name $clusterName -Location $location -Def ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [New-AzureHDInsightCluster], ConfigurationErrorsException
+ FullyQualifiedErrorId : System.Configuration.ConfigurationErrorsException,Microsoft.WindowsAzure.Management.HDInsight.Cmdlet.PSCmdlets.NewAzureHDInsightClusterCmdlet

我正在使用 Azure Powershell 版本 0.9.7 和 Azure SDK 2.7

最佳答案

回顾这一点,您遇到的问题现在可能已通过最新版本的 Azure PowerShell 得到解决。

要安装最新版本的 Azure PowerShell,请参阅此处: Installing Azure PowerShell

有关如何使用 HDInsight PowerShell cmdlet(例如 New-AzureRmHDInsightCluster)的示例,请参阅此处:Using HDInsight Azure PowerShell cmdlets

希望这会有所帮助!

关于azure - 使用powershell创建HDCluster,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32155732/

相关文章:

azure - 移至另一个订阅 : Cannot move resources because some site(s) are hosted by other resource group(s) but located in resource group 'XXX'

azure - 来自守护进程 : Get https://azure/v2/: dial tcp: lookup azure: no such host 的错误响应

hadoop - 从其他Blob容器在HDInsight中创建Hive表时出错:路径不合法

azure - Set-AzContext 在 Azure Cloud Shell 中有效,但在 Azure PowerShell 中无效

ASP.NET 在将所有 websocket 数据发送到客户端之前关闭连接

c# - 在 Azure Function 中使用命令式绑定(bind)在虚拟文件夹中搜索 Azure blob

hadoop - HDInsight安装后未创建HadoopDashboard

hadoop - Hive 函数 quarter() 返回 'invalid function'

azure - Get-AzApiManagementSubscription 命令返回订阅列表,但键值为空

azure - 是否可以在Azure DevOps中创建遵循幂等原则的PowerShell任务