在 Runbook 中使用时找不到 'Start-AzVM' 命令
Cannot find the 'Start-AzVM' command when used in a runbook
我正在努力 official tutorial from MS Azure team 到 运行 一个 PowerShell Workflow runbook
开始一个 VM
。但是当我开始阅读下面的 运行 书时(从教程的第 6 步开始),我收到如下所示的错误。 问题:我可能遗漏了什么,我们该如何解决这个问题?
rinbook 代码:
workflow MyFirstRunbook-Workflow
{
# Ensures that you do not inherit an AzContext in your runbook
Disable-AzContextAutosave –Scope Process
$Conn = Get-AutomationConnection -Name AzureRunAsConnection
Connect-AzAccount -ServicePrincipal -Tenant $Conn.TenantID -ApplicationId $Conn.ApplicationID -CertificateThumbprint $Conn.CertificateThumbprint
$AzureContext = Get-AzSubscription -SubscriptionId $Conn.SubscriptionID
Start-AzVM -Name 'vm-cs-web01' -ResourceGroupName 'rg-cs-ansible1' -AzContext $AzureContext
}
错误:
Failed At line:11 char:1
+ Start-AzVM -Name 'vm-cs-web01' -ResourceGroupName 'rg-cs-ansible1' -A ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Cannot find the 'Start-AzVM' command. If this command is defined as a workflow, ensure it is defined before the workflow that calls it. If it is a command intended to run directly within Windows PowerShell (or is not available on this system), place it in an InlineScript: 'InlineScript { Start-AzVM }'
Start-AzVM
is from the Az.Compute
模块,因此您需要将此模块导入您的自动化帐户。
要导入此模块,请转至 自动化帐户 -> 模块 -> 浏览库 -> 搜索 Az.Compute -> 导入
如果要导入所有 Az.*
模块,则只需从库中导入 Az
模块即可。要为您的自动化帐户导入它,请转至 Automation Account -> Modules -> Browse Gallery -> Search Az -> Import。
我正在努力 official tutorial from MS Azure team 到 运行 一个 PowerShell Workflow runbook
开始一个 VM
。但是当我开始阅读下面的 运行 书时(从教程的第 6 步开始),我收到如下所示的错误。 问题:我可能遗漏了什么,我们该如何解决这个问题?
rinbook 代码:
workflow MyFirstRunbook-Workflow
{
# Ensures that you do not inherit an AzContext in your runbook
Disable-AzContextAutosave –Scope Process
$Conn = Get-AutomationConnection -Name AzureRunAsConnection
Connect-AzAccount -ServicePrincipal -Tenant $Conn.TenantID -ApplicationId $Conn.ApplicationID -CertificateThumbprint $Conn.CertificateThumbprint
$AzureContext = Get-AzSubscription -SubscriptionId $Conn.SubscriptionID
Start-AzVM -Name 'vm-cs-web01' -ResourceGroupName 'rg-cs-ansible1' -AzContext $AzureContext
}
错误:
Failed At line:11 char:1
+ Start-AzVM -Name 'vm-cs-web01' -ResourceGroupName 'rg-cs-ansible1' -A ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Cannot find the 'Start-AzVM' command. If this command is defined as a workflow, ensure it is defined before the workflow that calls it. If it is a command intended to run directly within Windows PowerShell (or is not available on this system), place it in an InlineScript: 'InlineScript { Start-AzVM }'
Start-AzVM
is from the Az.Compute
模块,因此您需要将此模块导入您的自动化帐户。
要导入此模块,请转至 自动化帐户 -> 模块 -> 浏览库 -> 搜索 Az.Compute -> 导入
如果要导入所有 Az.*
模块,则只需从库中导入 Az
模块即可。要为您的自动化帐户导入它,请转至 Automation Account -> Modules -> Browse Gallery -> Search Az -> Import。