Azure 自动化 Runbook 类型Azure Automation runbook types

Azure 自动化流程自动化服务支持多种类型的 Runbook,如下表中所定义的那样。The Azure Automation process automation service supports several types of runbooks, as defined in the following table. 若要了解流程自动化环境,请参阅 Azure 自动化中的 Runbook 执行To learn about the process automation environment, see Runbook execution in Azure Automation.

类型Type 说明Description
图形Graphical 基于 Windows PowerShell 的图形 Runbook,完全在 Azure 门户中的图形编辑器中创建和编辑。Graphical runbook based on Windows PowerShell and created and edited completely in the graphical editor in Azure portal.
图形 PowerShell 工作流Graphical PowerShell Workflow 基于 Windows PowerShell 工作流的图形 Runbook,完全在 Azure 门户中的图形编辑器中创建和编辑。Graphical runbook based on Windows PowerShell Workflow and created and edited completely in the graphical editor in Azure portal.
PowerShellPowerShell 基于 Windows PowerShell 脚本的文本 Runbook。Text runbook based on Windows PowerShell scripting.
PowerShell 工作流PowerShell Workflow 基于 Windows PowerShell 工作流脚本的文本 Runbook。Text runbook based on Windows PowerShell Workflow scripting.
PythonPython 基于 Python 脚本的文本 Runbook。Text runbook based on Python scripting.

在确定要用于特定 Runbook 的类型时,请注意以下事项。Take into account the following considerations when determining which type to use for a particular runbook.

  • 无法将 Runbook 从图形转换为文本类型,反之亦然。You can't convert runbooks from graphical to text type, or the other way around.
  • 将不同类型的 Runbook 用作子 Runbook 时存在各种限制。There are limitations when using runbooks of different types as child runbooks. 有关详细信息,请参阅 Azure 自动化中的子 RunbookFor more information, see Child runbooks in Azure Automation.

图形 RunbookGraphical runbooks

可以在 Azure 门户中使用图形编辑器创建和编辑图形 Runbook 与图形 PowerShell 工作流 Runbook。You can create and edit graphical and graphical PowerShell Workflow runbooks using the graphical editor in the Azure portal. 但是,不能通过其他工具创建或编辑此类型的 Runbook。However, you can't create or edit this type of runbook with another tool. 图形 Runbook 的主要功能:Main features of graphical runbooks:

  • 可以导出到自动化帐户中的文件,然后导入到另一个自动化帐户中。Can be exported to files in your Automation account and then imported into another Automation account.
  • 生成 PowerShell 代码。Generate PowerShell code.
  • 在导入过程中,可以转换为图形 PowerShell 工作流 runbook,或者由该工作流 runbook 转换而来。Can be converted to or from graphical PowerShell Workflow runbooks during import.

优点Advantages

  • 使用可视化的“插入-链接-配置”创作模型。Use visual insert-link-configure authoring model.
  • 关注数据在流程中如何流动。Focus on how data flows through the process.
  • 直观展示管理流程。Visually represent management processes.
  • 能够以子 Runbook 的形式包括其他 Runbook,以创建高级工作流。Include other runbooks as child runbooks to create high-level workflows.
  • 促进模块化编程。Encourage modular programming.

限制Limitations

  • 无法在 Azure 门户外创建或编辑。Can't create or edit outside the Azure portal.
  • 可能需要使用包含 PowerShell 代码的代码活动,才能执行复杂逻辑。Might require a code activity containing PowerShell code to execute complex logic.
  • 无法转换为文本格式之一,也无法将文本 Runbook 转换为图形格式。Can't convert to one of the text formats, nor can you convert a text runbook to graphical format.
  • 不能查看或直接编辑由图形工作流创建的 PowerShell 代码。Can't view or directly edit PowerShell code that the graphical workflow creates. 可以查看你在任何代码活动中创建的代码。You can view the code you create in any code activities.
  • 无法在 Linux 混合 Runbook 辅助角色中运行 Runbook。Can't run runbooks on a Linux Hybrid Runbook Worker. 请参阅使用混合 Runbook 辅助角色使数据中心或云端的资源实现自动化See Automate resources in your datacenter or cloud by using Hybrid Runbook Worker.

PowerShell RunbookPowerShell runbooks

基于 Windows PowerShell 的 PowerShell Runbook。PowerShell runbooks are based on Windows PowerShell. 可以在 Azure 门户中使用文本编辑器直接编辑 Runbook 的代码。You directly edit the code of the runbook using the text editor in the Azure portal. 还可以使用任何脱机文本编辑器,以便 导入 Runbook 到 Azure 自动化中。You can also use any offline text editor and import the runbook into Azure Automation.

优点Advantages

  • 通过 PowerShell 代码来实现所有复杂的逻辑,没有 PowerShell 工作流的各种额外的复杂操作。Implement all complex logic with PowerShell code without the additional complexities of PowerShell Workflow.
  • 与 PowerShell 工作流 Runbook 相比,启动速度更快,因为它们在运行前不需要经过编译。Start faster than PowerShell Workflow runbooks, since they don't need to be compiled before running.
  • 在 Azure 中和适用于 Windows 和 Linux 的混合 Runbook 辅助角色上运行。Run in Azure and on Hybrid Runbook Workers for both Windows and Linux.

限制Limitations

  • 你必须熟悉 PowerShell 脚本。You must be familiar with PowerShell scripting.
  • Runbook 无法使用并行处理并行执行多个操作。Runbooks can't use parallel processing to execute multiple actions in parallel.
  • 存在错误时,Runbook 无法使用检查点来恢复 Runbook。Runbooks can't use checkpoints to resume runbook if there's an error.
  • 使用用于创建新作业的 Start-AzureAutomationRunbook cmdlet 只能将 PowerShell 工作流 Runbook 和图形 Runbook 包括为子 Runbook。You can include only PowerShell Workflow runbooks and graphical runbooks as child runbooks by using the Start-AzureAutomationRunbook cmdlet, which creates a new job.

已知问题Known issues

下面是 PowerShell Runbook 的当前已知问题:The following are current known issues with PowerShell runbooks:

  • PowerShell Runbook 无法检索未加密且值为 null 的变量资产PowerShell runbooks can't retrieve an unencrypted variable asset with a null value.
  • PowerShell Runbook 无法检索名称中包含 *~* 的变量资产。PowerShell runbooks can't retrieve a variable asset with *~* in the name.
  • 在 PowerShell Runbook 中,处于循环状态的 Get-Process 操作在经历大约 80 次迭代后可能会崩溃。A Get-Process operation in a loop in a PowerShell runbook can crash after about 80 iterations.
  • 如果 PowerShell Runbook 尝试一次性将大量数据写入输出流中,则可能会发生故障。A PowerShell runbook can fail if it tries to write a large amount of data to the output stream at once. 通常,在处理大型对象时,可以通过让 runbook 只输出所需信息来避免出现这种问题。You can typically work around this issue by having the runbook output just the information needed to work with large objects. 例如,可以像 Get-Process | Select ProcessName, CPU 一样让 cmdlet 仅输出必需的参数,而不是使用不带限制的 Get-ProcessFor example, instead of using Get-Process with no limitations, you can have the cmdlet output just the required parameters as in Get-Process | Select ProcessName, CPU.

PowerShell 工作流 RunbookPowerShell Workflow runbooks

PowerShell 工作流 Runbook 是基于 Windows PowerShell 工作流的文本 Runbook。PowerShell Workflow runbooks are text runbooks based on Windows PowerShell Workflow. 可以在 Azure 门户中使用文本编辑器直接编辑 Runbook 的代码。You directly edit the code of the runbook using the text editor in the Azure portal. 还可以使用任何脱机文本编辑器,以便 导入 Runbook 到 Azure 自动化中。You can also use any offline text editor and import the runbook into Azure Automation.

优点Advantages

  • 通过 PowerShell 工作流代码实现所有复杂的逻辑。Implement all complex logic with PowerShell Workflow code.
  • 出现错误时,请使用检查点来恢复操作。Use checkpoints to resume operation if there's an error.
  • 使用并行处理来并行执行多个操作。Use parallel processing to do multiple actions in parallel.
  • 能够以子 Runbook 的形式包括其他图形 Runbook 和 PowerShell 工作流 Runbook,以创建高级工作流。Can include other graphical runbooks and PowerShell Workflow runbooks as child runbooks to create high-level workflows.

限制Limitations

  • 你必须熟悉 PowerShell 工作流。You must be familiar with PowerShell Workflow.
  • Runbook 还必须处理与 PowerShell 工作流相关的其他复杂问题,例如反序列化的对象Runbooks must deal with the additional complexity of PowerShell Workflow, such as deserialized objects.
  • 与 PowerShell Runbook 相比,Runbook 需要更长时间来启动,因为它们在运行前需要进行编译。Runbooks take longer to start than PowerShell runbooks since they must be compiled before running.
  • 若要以子 Runbook 的形式包括 PowerShell Runbook,只能使用 Start-AzAutomationRunbook cmdlet。You can only include PowerShell runbooks as child runbooks by using the Start-AzAutomationRunbook cmdlet.
  • 无法在 Linux 混合 Runbook 辅助角色中运行 Runbook。Runbooks can't run on a Linux Hybrid Runbook Worker.

Python RunbookPython runbooks

在 Python 2 下编译 Python runbook。Python runbooks compile under Python 2. 可以在 Azure 门户中使用文本编辑器直接编辑 Runbook 的代码。You can directly edit the code of the runbook using the text editor in the Azure portal. 还可以使用脱机文本编辑器,将 Runbook 导入到 Azure 自动化中。You can also use an offline text editor and import the runbook into Azure Automation.

优点Advantages

  • 使用功能强大的 Python 库。Use the robust Python libraries.
  • 可以在 Azure 中运行,也可以在 Linux 混合 Runbook 辅助角色上运行。Can run in Azure or on Linux Hybrid Runbook Workers. 在安装了 python2.7 的情况下,支持 Windows 混合 Runbook 辅助角色。Windows Hybrid Runbook Workers are supported with python2.7 installed.

限制Limitations

  • 你必须熟悉 Python 脚本。You must be familiar with Python scripting.
  • 目前仅支持 Python 2。Only Python 2 is supported presently. 任何特定于 Python 3 的函数都会失败。Any Python 3-specific functions fail.
  • 若要使用第三方库,必须将包导入到自动化帐户中。To use third-party libraries, you must import the packages into the Automation account.

后续步骤Next steps