您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

Azure 自动化的 Runbook 和模块库Runbook and module galleries for Azure Automation

无需在 Azure 自动化中创建自己的 Runbook 和模块,即可访问 Microsoft 和社区构建的各种方案。Rather than creating your own runbooks and modules in Azure Automation, you can access a variety of scenarios that have already been built by Microsoft and the community. 可以在不加以修改的情况下直接使用这些方案,或者使用它们作为起点并根据具体的要求进行编辑。You can either use these scenarios without modification or you can use them as a starting point and edit them for your specific requirements.

可以从 Runbook 库获取 Runbook,并从PowerShell 库获取模块。You can get runbooks from the Runbook Gallery and modules from the PowerShell Gallery. 还可以通过共享开发的方案来为社区做出贡献。You can also contribute to the community by sharing scenarios that you develop.

Runbook 库提供各种来自 Microsoft 的 Runbook,以及可导入 Azure 自动化中的社区。The Runbook Gallery provides a variety of runbooks from Microsoft and the community that you can import into Azure Automation. 可以从 TechNet 脚本中心托管的库下载 Runbook,或者在 Azure 经典门户或 Azure 门户中直接从该库导入 Runbook。You can either download a runbook from the gallery, which is hosted in the TechNet Script Center, or you can directly import runbooks from the gallery from either the Azure classic portal or Azure portal.

直接从 Runbook 库导入只能使用 Azure 经典门户或 Azure 门户来完成。You can only import directly from the Runbook Gallery using the Azure classic portal or Azure portal. 而不能使用 Windows PowerShell 执行此功能。You cannot perform this function using Windows PowerShell.

备注

应验证从 Runbook 库获取的任何 Runbook 的内容,在生产环境中安装和运行这些 Runbook 时,请谨慎操作。You should validate the contents of any runbooks that you get from the Runbook Gallery and use extreme caution in installing and running them in a production environment.|

  1. 在 Azure 门户中,依次单击“新建”、“应用服务”、“自动化”、“Runbook”、“从库中”。In the Azure portal, click, New, App Services, Automation, Runbook, From Gallery.
  2. 选择一个类别以查看相关的 Runbook,并选择一个 Runbook 以查看其详细信息。Select a category to view related runbooks, and select a runbook to view its details. 选择所需的 Runbook 后,单击右箭头按钮。When you select the runbook you want, click the right arrow button.

    Runbook 库

  3. 查看该 Runbook 的内容,并记下说明中所述的任何要求。Review the contents of the runbook and note any requirements in the description. 完成后,单击右箭头按钮。Click the right arrow button when you’re done.
  4. 输入 Runbook 详细信息,并单击复选标记按钮。Enter the runbook details and then click the checkmark button. Runbook 名称已填入。The runbook name is already filled in.
  5. Runbook 将出现在自动化帐户的“Runbook”选项卡中。The runbook appears on the Runbooks tab for the Automation Account.
  1. 在 Azure 门户中,打开自动化帐户。In the Azure portal, open your Automation account.
  2. 单击“Runbook” 磁贴打开 Runbook 的列表。Click on the Runbooks tile to open the list of runbooks.
  3. 单击“浏览库”按钮。Click Browse gallery button.

    “浏览库”按钮

  4. 找到所需的库项,选择它以查看其详细信息。Locate the gallery item you want and select it to view its details.

    浏览库

  5. 单击“查看源项目”以在 TechNet 脚本中心查看该项。Click on View source project to view the item in the TechNet Script Center.
  6. 要导入项,请单击它以查看其详细信息,并单击“导入”按钮。To import an item, click on it to view its details and then click the Import button.

    “导入”按钮

  7. 可选择更改 Runbook 的名称,并单击“确定”导入该 Runbook。Optionally, change the name of the runbook and then click OK to import the runbook.
  8. Runbook 将出现在自动化帐户的“Runbook”选项卡中。The runbook appears on the Runbooks tab for the Automation Account.

Microsoft 建议将 Runbook 添加到认为对其他客户有用的 Runbook 库中。Microsoft encourages you to add runbooks to the Runbook Gallery that you think would be useful to other customers. 可通过将 Runbook 上传到脚本中心来添加它,并同时考虑以下详细信息。You can add a runbook by uploading it to the Script Center taking into account the following details.

  • 必须为向导中要显示的 Runbook 指定“Microsoft Azure”作为“类别”,指定“自动化”作为“子类别”。You must specify Windows Azure for the Category and Automation for the Subcategory for the runbook to be displayed in the wizard.
  • 上传内容必须是单个 .ps1 或 .graphrunbook 文件。The upload must be a single .ps1 or .graphrunbook file. 如果 Runbook 需要任何模块、子 Runbook 或资产,则你应该在提交内容的说明和 Runbook 的注释部分列出这些内容。If the runbook requires any modules, child runbooks, or assets, then you should list those in the description of the submission and in the comments section of the runbook. 如果方案需要多个 Runbook,请单独上传每个 Runbook 并在各自的说明中列出相关 Runbook 的名称。If you have a scenario requiring multiple runbooks, then upload each separately and list the names of the related runbooks in each of their descriptions. 请确保使用相同的标记,以便它们在同一类别中显示。Make sure that you use the same tags so that they show up in the same category. 用户阅读说明后才会知道,方案要正常工作需要其他 Runbook。A user will have to read the description to know that other runbooks are required the scenario to work.
  • 如果要发布“图形 Runbook”(非图形工作流),则添加标记“GraphicalPS”。Add the tag "GraphicalPS" if you are publishing a Graphical runbook (not a Graphical Workflow).
  • 使用“插入代码段”图标将 PowerShell 或 PowerShell 工作流代码片段插入说明中。Insert either a PowerShell or PowerShell Workflow code snippet into the description using Insert code section icon.
  • Runbook 库结果中会显示上传摘要,因此,应该提供详细信息,以帮助用户明确 Runbook 的功能。The Summary for the upload is displayed in the Runbook Gallery results so you should provide detailed information that helps a user identify the functionality of the runbook.
  • 应该为上传内容分配一到三个以下标记。You should assign one to three of the following Tags to the upload. Runbook 会在向导中与标记匹配的类别下列出。The runbook is listed in the wizard under the categories that match its tags. 该向导忽略不在此列表中的所有标记。Any tags not on this list are ignored by the wizard. 如果未指定任何匹配的标记,则 Runbook 会在“其他”类别下列出。If you don’t specify any matching tags, the runbook is listed under the Other category.

    • 备份Backup
    • 容量管理Capacity Management
    • 更改控制Change Control
    • 合规性Compliance
    • 开发/测试环境Dev / Test Environments
    • 灾难恢复Disaster Recovery
    • 监视Monitoring
    • 修补Patching
    • 设置Provisioning
    • 补救Remediation
    • VM 生命周期管理VM Lifecycle Management
  • 自动化每小时更新一次该库,因此,无法立即看见上传内容。Automation updates the Gallery once an hour, so you won’t see your contributions immediately.

PowerShell 模块包含可以在 Runbook 中使用的 cmdlet,并可以在 PowerShell 库中找到可在 Azure 自动化中安装的现有模块。PowerShell modules contain cmdlets that you can use in your runbooks, and existing modules that you can install in Azure Automation are available in the PowerShell Gallery. 可以从 Azure 门户启动此库,并将这些模块直接安装到 Azure 自动化中,也可以下载并手动安装这些模块。You can launch this gallery from the Azure portal and install them directly into Azure Automation or you can download them and install them manually. 不能直接从 Azure 经典门户安装这些模块,但可以在下载之后进行安装,就像使用其他模块一样。You cannot install the modules directly from the Azure classic portal, but you can download them install them as you would any other module.

  1. 在 Azure 门户中,打开自动化帐户。In the Azure portal, open your Automation account.
  2. 在“共享资源”中选择“模块”,打开模块列表。Select Modules under Shared Resources to open the list of modules.
  3. 请单击页面顶部的“浏览全部”。Click Browse gallery from the top of the page.

    模块库

  4. 在“浏览库”页,可以按以下字段进行搜索:On the Browse gallery page, you can search by the following fields:

    • 模块名称Module Name
    • 标记Tags
    • 作者Author
    • Cmdlet/DSC 资源名称Cmdlet/DSC resource name
  5. 找到感兴趣的模块并选择它以查看其详细信息。Locate a module that you're interested in and select it to view its details.
    当钻取到特定模块时,可以查看有关该模块的详细信息,其中包含返回 PowerShell 库的链接、任何必需的依赖项,以及该模块包含的所有 cmdlet 和/或 DSC 资源。When you drill into a specific module, you can view more information about the module, including a link back to the PowerShell Gallery, any required dependencies, and all of the cmdlets and/or DSC resources that the module contains.

    PowerShell 模块详细信息

  6. 要直接将模块安装到 Azure 自动化中,请单击“导入”按钮。To install the module directly into Azure Automation, click the Import button.

    “导入模块”按钮

  7. 在“导入”页中单击“导入”按钮时,会看到将要导入的模块名称。When you click the Import button, on the Import pane, you see the module name that you are about to import. 如果安装了所有依赖项,“确定”按钮将处于活动状态。If all the dependencies are installed, the OK button is activated. 如果缺少依赖项,则需要在导入此模块前导入这些依赖项。If you are missing dependencies, you need to import those before you can import this module.
  8. 单击“确定”导入模块。Click OK to import the module. Azure 自动化将模块导入帐户时,它提取有关该模块和 cmdlet 的元数据。While Azure Automation imports a module to your account, it extracts metadata about the module and the cmdlets.

    “导入模块”页

    这可能需要几分钟才能完成,因为需要提取每个活动。This may take a couple of minutes since each activity needs to be extracted.

  9. 将收到正在部署该模块的初始通知;完成此过程后,还会收到另一通知。You receive an initial notification that the module is being deployed and another notification when it has completed.
  10. 导入模块后,会看到可用的活动,并可以在 Runbook 和 Desired State Configuration 中使用其资源。After the module is imported, you can see the available activities, and you can use its resources in your runbooks and Desired State Configuration.

请求 Runbook 或模块Requesting a runbook or module

可以将请求发送到用户之声You can send requests to User Voice. 如果需要 Runbook 编写帮助,或对 PowerShell 存有疑问,请将问题发布到我们的论坛If you need help writing a runbook or have a question about PowerShell, post a question to our forum.

后续步骤Next Steps