Azure 门户测试窗格(自动化帐户)上无法识别 Azure 资源管理器 powershell cmdlet
Azure Resource Manager powershell cmdlet is not recognized on azure portal test pane (Automation accounts)
在 Windows Azure 门户中,从我的自动化帐户(自动化帐户 > myAutomation > Runbooks > MyRunbook > 编辑 PowerShell 工作流 Runbook > 测试),我正在尝试使用 Azure 资源测试 powershell 脚本管理器库,用于迁移目的。
我写了一小段 powershell 脚本并在测试窗格中对其进行了测试。
我遇到一条错误消息:
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 portal 不识别 ARM 库。
我肯定错过了什么,但是什么? :)
感谢您的帮助。
您需要将这些模块导入您的 Azure 自动化帐户。在这种情况下,您需要 AzureRM.HDInsight
模块。有关如何导入模块的信息,请参阅此 link:https://docs.microsoft.com/en-us/azure/automation/automation-runbook-gallery#modules-in-powershell-gallery
问题是,默认情况下,您的帐户只会获得部分 Azure Powershell 模块,其余的您必须手动安装。
我所理解的问题是因为工作流范围。
我建议您使用函数而不是工作流并尝试一次。
这样您就可以将问题分为库问题或范围问题。
如果问题出在范围上并且您想使用工作流,那么我们会在工作流的每个范围内使用传递参数。以便 ARM 库可以理解范围内的 cmdlet "Start-AzureRmHDInsightJob" 和 "Wait-AzureRmHDInsightJob"。
对于您的回答,如果使用函数和全局变量,Azure cmdlet 在我的中可以正常工作。
在 Windows Azure 门户中,从我的自动化帐户(自动化帐户 > myAutomation > Runbooks > MyRunbook > 编辑 PowerShell 工作流 Runbook > 测试),我正在尝试使用 Azure 资源测试 powershell 脚本管理器库,用于迁移目的。 我写了一小段 powershell 脚本并在测试窗格中对其进行了测试。 我遇到一条错误消息:
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 portal 不识别 ARM 库。
我肯定错过了什么,但是什么? :) 感谢您的帮助。
您需要将这些模块导入您的 Azure 自动化帐户。在这种情况下,您需要 AzureRM.HDInsight
模块。有关如何导入模块的信息,请参阅此 link:https://docs.microsoft.com/en-us/azure/automation/automation-runbook-gallery#modules-in-powershell-gallery
问题是,默认情况下,您的帐户只会获得部分 Azure Powershell 模块,其余的您必须手动安装。
我所理解的问题是因为工作流范围。
我建议您使用函数而不是工作流并尝试一次。 这样您就可以将问题分为库问题或范围问题。
如果问题出在范围上并且您想使用工作流,那么我们会在工作流的每个范围内使用传递参数。以便 ARM 库可以理解范围内的 cmdlet "Start-AzureRmHDInsightJob" 和 "Wait-AzureRmHDInsightJob"。
对于您的回答,如果使用函数和全局变量,Azure cmdlet 在我的中可以正常工作。