在 Windows Azure 门户中,从我的自动化帐户(自动化帐户 > myAutomation > Runbooks > MyRunbook > 编辑 PowerShell 工作流 Runbook > 测试),我尝试使用 Azure 资源管理器库测试 powershell 脚本,以用于迁移目的。 我编写了一小段 powershell 脚本并在测试 Pane 中对其进行了测试。 我遇到错误消息:
The term 'New-AzureRmHDInsightHiveJobDefinition' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
我想直接从 Windows Azure 门户测试它,因为我需要使用“Get-AutomationPSCredential”等函数的一些结果。
PowerShell 脚本示例
workflow Runbook_Test
{
param(
[parameter(Mandatory=$True)]
[string] $HDInsightAdminCredendialsName
)
$hdInsightCredentials = Get-AutomationPSCredential -Name $HDInsightAdminCredendialsName
InlineScript {
$creds = $using:hdInsightCredentials
$clusterName = 'clusterName'
$query = 'A QUERY INSIDE'
$jobDef = New-AzureRmHDInsightHiveJobDefinition -Query $query;
$hiveJob = Start-AzureRmHDInsightJob -JobDefinition $jobDef -ClusterName $clusterName -HttpCredential $creds
Wait-AzureRmHDInsightJob -JobId $hiveJob.JobId -ClusterName $clusterName -HttpCredential $creds
}
}
我对 cmdlet“Start-AzureRmHDInsightJob”和“Wait-AzureRmHDInsightJob”也有同样的问题。就像 azure 门户无法识别 ARM 库一样。
我肯定错过了什么,但是什么? :) 感谢您的帮助。
最佳答案
您需要将这些模块导入您的 Azure 自动化帐户。在这种情况下,您需要 AzureRM.HDInsight
模块。有关如何导入模块的信息,请参阅此链接:https://learn.microsoft.com/en-us/azure/automation/automation-runbook-gallery#modules-in-powershell-gallery
问题是,默认情况下,您的帐户仅获得部分 Azure Powershell 模块,其余的则必须手动安装。
关于powershell - Azure 资源管理器 powershell cmdlet 在 azure 门户测试 Pane (自动化帐户)上无法识别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40899342/