【发布时间】:2016-06-09 21:40:39
【问题描述】:
我尝试在 Azure 中创建 HDInsight Storm 群集并将其添加到我的虚拟网络。但由于某种原因,我总是收到以下错误消息:
集群创建前验证失败:由于用户错误,集群 xxxxxxx 的虚拟网络验证失败验证报告:用户订阅 xxxxxxx 没有任何虚拟网络。例外:
Powershell 脚本如下所示:
####################################
# Set these variables
####################################
$nameToken = "xxxxxx"
$httpUserName = "xxxxxx"
$httpPassword = "xxxxxx"
$ClusterTyp = "Storm"
$namePrefix = $nameToken.ToLower()
$resourceGroupName = $namePrefix
$hdinsightClusterName = $namePrefix +"storm"
$defaultStorageAccountName = $namePrefix +"storm"
$defaultBlobContainerName = $hdinsightClusterName
$location = "North Europe"
$clusterSizeInNodes = 1
#Virtual Network
$NetworkName = "xxxxxx"
$subnetName = "xxxxxx"
# Treat all errors as terminating
$ErrorActionPreference = "Stop"
###########################################
# Connect to Azure
###########################################
#region - Connect to Azure subscription
Write-Host "`nConnecting to your Azure subscription ..." -ForegroundColor Green
try{Get-AzureRmContext}
catch{Login-AzureRmAccount}
#endregion
###########################################
# Preapre default storage account and container
###########################################
New-AzureRmStorageAccount -ResourceGroupName $resourceGroupName -Name $defaultStorageAccountName -Type Standard_GRS -Location $location
$defaultStorageAccountKey = (Get-AzureRmStorageAccountKey -ResourceGroupName $resourceGroupName -Name $defaultStorageAccountName).Key1
$defaultStorageContext = New-AzureStorageContext -StorageAccountName $defaultStorageAccountName -StorageAccountKey $defaultStorageAccountKey
New-AzureStorageContainer -Name $hdinsightClusterName -Context $defaultStorageContext
###########################################
# Create the cluster
###########################################
$vnet = (Get-AzureRmVirtualNetwork -ResourceGroupName $ResourceGroupName -Name $NetworkName).Id
$httpPW = ConvertTo-SecureString -String $httpPassword -AsPlainText -Force
$httpCredential = New-Object System.Management.Automation.PSCredential($httpUserName,$httpPW)
Write-Host "Create HDInsight Cluster" -ForegroundColor Yellow
New-AzureRmHDInsightCluster -ResourceGroupName $resourceGroupName -ClusterName $hdinsightClusterName -Location $location -ClusterSizeInNodes $clusterSizeInNodes -ClusterType $ClusterTyp -OSType Windows -Version "3.2" -HttpCredential $httpCredential -DefaultStorageAccountName "$defaultStorageAccountName.blob.core.windows.net" -DefaultStorageAccountKey $defaultStorageAccountKey -DefaultStorageContainer $hdinsightClusterName -VirtualNetworkId $vnet -SubnetName $subnetName
Write-Host "HDInsight Cluster Created" -ForegroundColor Green
####################################
# Verify the cluster
####################################
Get-AzureRmHDInsightCluster -ClusterName $hdinsightClusterName
如果我在没有以下参数的情况下运行脚本,它似乎可以正常工作:
-VirtualNetworkId $vnet -SubnetName $subnetName
当然,如果没有这些参数,集群将不会被添加到虚拟网络中。 虚拟网络肯定存在,如果我在门户中手动添加集群,我可以将其添加到相应的虚拟网络中。
已经感谢您的帮助。
亲切的问候
【问题讨论】:
标签: powershell azure azure-hdinsight azure-virtual-network