Azure 自动化 Runbook 类型Azure Automation runbook types

下表定义了 Azure 自动化流程自动化功能支持的几种 Runbook 类型。The Azure Automation Process Automation feature supports several types of runbooks, as defined in the following table. 若要了解有关流程自动化环境的信息,请参阅在 Azure 自动化中执行 RunbookTo 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:

  • 可以将图形 Runbook 导出到自动化帐户中的文件中,然后将其导入到另一个自动化帐户。Can be exported to files in your Automation account and then imported into another Automation account.
  • 生成 PowerShell 代码。Generate PowerShell code.
  • 在导入过程中,可以将图形 Runbook 转换为图形 PowerShell 工作流 Runbook,也可以将图形 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-AzAutomationRunbook(用于创建新作业)仅将 PowerShell 工作流 Runbook 和图形 Runbook 以子 Runbook 的形式包括在内。You can include only PowerShell Workflow runbooks and graphical runbooks as child runbooks by using the Start-AzAutomationRunbook 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. 例如,可以让 cmdlet 仅输出所需的参数,如在 Get-Process | Select ProcessName, CPU 中那样,而不是不受限地使用 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.
  • 可以使用 Start-AzAutomationRunbook cmdlet 仅将 PowerShell Runbook 作为子 Runbook 包括在内。You can only include PowerShell runbooks as child runbooks by using the Start-AzAutomationRunbook cmdlet.
  • Runbook 无法在 Linux 混合 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. 如果安装了 python 2.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