将 Azure 自动化资源添加到管理解决方案(预览版)Adding Azure Automation resources to a management solution (Preview)

备注

这是用于创建当前处于预览版的管理解决方案的初步文档。This is preliminary documentation for creating management solutions which are currently in preview. 如下所述的全部架构均会有变动。Any schema described below is subject to change.

管理解决方案通常在 Azure 自动化中包含 Runbook 以自动执行各种进程,例如收集和处理监控数据。Management solutions will typically include runbooks in Azure Automation to automate processes such as collecting and processing monitoring data. 除了 Runbook,自动化帐户还包含资产,例如支持在解决方案中使用的 Runbook 的变量和计划。In addition to runbooks, Automation accounts includes assets such as variables and schedules that support the runbooks used in the solution. 本文介绍如何在解决方案中包含 Runbook 和其相关资源。This article describes how to include runbooks and their related resources in a solution.

备注

本文中的示例使用管理解决方案需要或通用的参数和变量,在 Azure 中设计和开发解决方案中对它们进行了介绍。The samples in this article use parameters and variables that are either required or common to management solutions and described in Design and build a management solution in Azure

先决条件Prerequisites

本文假设已熟悉以下信息。This article assumes that you're already familiar with the following information.

自动化帐户Automation account

Azure 自动化中的所有资源都包含在自动化帐户中。All resources in Azure Automation are contained in an Automation account. Log Analytics 工作区和自动化帐户中所述,自动化帐户不包括在管理解决方案中,但必须存在才可以安装解决方案。As described in Log Analytics workspace and Automation account the Automation account isn't included in the management solution but must exist before the solution is installed. 如果没有,解决方案安装会失败。If it isn't available, then the solution install will fail.

每个自动化资源的名称都包含其自动化帐户的名称。The name of each Automation resource includes the name of its Automation account. 这是在具有 accountName 参数的解决方案中完成的,如以下 Runbook 资源示例所示。This is done in the solution with the accountName parameter as in the following example of a runbook resource.

"name": "[concat(parameters('accountName'), '/MyRunbook'))]"

RunbookRunbooks

应在解决方案文件中包含解决方案所使用的任何 runbook,以便在安装解决方案时创建这些 runbook。You should include any runbooks used by the solution in the solution file so that they're created when the solution is installed. 但是,不能在模板中包含 runbook 的正文,因此应将 runbook 发布到任何安装解决方案的用户均可访问的公共位置。You cannot contain the body of the runbook in the template though, so you should publish the runbook to a public location where it can be accessed by any user installing your solution.

Azure 自动化 runbook 资源具有类型 Microsoft.Automation/automationAccounts/runbooks 和以下结构。Azure Automation runbook resources have a type of Microsoft.Automation/automationAccounts/runbooks and have the following structure. 这包括常见变量和参数,以便可以将此代码片段复制并粘贴到解决方案文件,并更改参数名称。This includes common variables and parameters so that you can copy and paste this code snippet into your solution file and change the parameter names.

{
    "name": "[concat(parameters('accountName'), '/', variables('Runbook').Name)]",
    "type": "Microsoft.Automation/automationAccounts/runbooks",
    "apiVersion": "[variables('AutomationApiVersion')]",
    "dependsOn": [
    ],
    "location": "[parameters('regionId')]",
    "tags": { },
    "properties": {
        "runbookType": "[variables('Runbook').Type]",
        "logProgress": "true",
        "logVerbose": "true",
        "description": "[variables('Runbook').Description]",
        "publishContentLink": {
            "uri": "[variables('Runbook').Uri]",
            "version": [variables('Runbook').Version]"
        }
    }
}

下表介绍了 runbook 的属性。The properties for runbooks are described in the following table.

属性Property 说明Description
runbookTyperunbookType 指定 Runbook 的类型。Specifies the types of the runbook.

脚本 - PowerShell 脚本Script - PowerShell script
PowerShell - PowerShell 工作流PowerShell - PowerShell workflow
GraphPowerShell - 图形 PowerShell 脚本 RunbookGraphPowerShell - Graphical PowerShell script runbook
GraphPowerShellWorkflow - 图形 PowerShell 工作流 RunbookGraphPowerShellWorkflow - Graphical PowerShell workflow runbook
logProgresslogProgress 指定是否应为 Runbook 生成进度记录Specifies whether progress records should be generated for the runbook.
logVerboselogVerbose 指定是否应为 Runbook 生成详细记录Specifies whether verbose records should be generated for the runbook.
说明description Runbook 的可选说明。Optional description for the runbook.
publishContentLinkpublishContentLink 指定 Runbook 的内容。Specifies the content of the runbook.

uri - Runbook 内容的 URI。uri - Uri to the content of the runbook. 这会是 PowerShell 和脚本 Runbook 的 .ps1 文件,以及为图形 Runbook 导出的图形 Runbook 文件。This will be a .ps1 file for PowerShell and Script runbooks, and an exported graphical runbook file for a Graph runbook.
version - 自己跟踪的 Runbook 版本。version - Version of the runbook for your own tracking.

自动化作业Automation jobs

在 Azure 自动化中启动 runbook 时,会创建一个自动化作业。When you start a runbook in Azure Automation, it creates an automation job. 可以会自动化作业资源添加到解决方案,以便在安装管理解决方案时自动启动 runbook。You can add an automation job resource to your solution to automatically start a runbook when the management solution is installed. 此方法通常用于启动用于对解决方案进行初始配置的 runbook。This method is typically used to start runbooks that are used for initial configuration of the solution. 若要定期启动 runbook,请创建计划作业计划To start a runbook at regular intervals, create a schedule and a job schedule

作业资源具有类型 Microsoft.Automation/automationAccounts/jobs 和以下结构。Job resources have a type of Microsoft.Automation/automationAccounts/jobs and have the following structure. 这包括常见变量和参数,以便可以将此代码片段复制并粘贴到解决方案文件,并更改参数名称。This includes common variables and parameters so that you can copy and paste this code snippet into your solution file and change the parameter names.

{
  "name": "[concat(parameters('accountName'), '/', parameters('Runbook').JobGuid)]",
  "type": "Microsoft.Automation/automationAccounts/jobs",
  "apiVersion": "[variables('AutomationApiVersion')]",
  "location": "[parameters('regionId')]",
  "dependsOn": [
    "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'), '/runbooks/', variables('Runbook').Name)]"
  ],
  "tags": { },
  "properties": {
    "runbook": {
      "name": "[variables('Runbook').Name]"
    },
    "parameters": {
      "Parameter1": "[[variables('Runbook').Parameter1]",
      "Parameter2": "[[variables('Runbook').Parameter2]"
    }
  }
}

下表介绍了自动化作业的属性。The properties for automation jobs are described in the following table.

属性Property 说明Description
Runbookrunbook 包含要启动的 Runbook 名称的单个 name 实体。Single name entity with the name of the runbook to start.
参数parameters Runbook 所需的每个参数值的实体。Entity for each parameter value required by the runbook.

作业包括 Runbook 名称和发送到 Runbook 的任何参数值。The job includes the runbook name and any parameter values to be sent to the runbook. 作业应依赖于自必须在作业之前创建 Runbook 以来启动的 Runbook。The job should depend on the runbook that it's starting since the runbook must be created before the job. 如果有多个应启动的 runbook,则可以通过让一个作业依赖于任何其他应先运行的作业来定义其顺序。If you have multiple runbooks that should be started you can define their order by having a job depend on any other jobs that should be run first.

作业资源的名称必须包含一个通常由参数分配的 GUID。The name of a job resource must contain a GUID which is typically assigned by a parameter. 有关 GUID 参数的详细信息,请参阅在 Azure 中创建管理解决方案文件You can read more about GUID parameters in Creating a management solution file in Azure.

证书Certificates

Azure 自动化证书具有类型 Microsoft.Automation/automationAccounts/certificates 和以下结构。Azure Automation certificates have a type of Microsoft.Automation/automationAccounts/certificates and have the following structure. 这包括常见变量和参数,以便可以将此代码片段复制并粘贴到解决方案文件,并更改参数名称。This includes common variables and parameters so that you can copy and paste this code snippet into your solution file and change the parameter names.

{
  "name": "[concat(parameters('accountName'), '/', variables('Certificate').Name)]",
  "type": "Microsoft.Automation/automationAccounts/certificates",
  "apiVersion": "[variables('AutomationApiVersion')]",
  "location": "[parameters('regionId')]",
  "tags": { },
  "dependsOn": [
  ],
  "properties": {
    "base64Value": "[variables('Certificate').Base64Value]",
    "thumbprint": "[variables('Certificate').Thumbprint]"
  }
}

下表介绍了证书资源的属性。The properties for Certificates resources are described in the following table.

属性Property 说明Description
base64Valuebase64Value 证书的 Base 64 值。Base 64 value for the certificate.
thumbprintthumbprint 证书的指纹。Thumbprint for the certificate.

凭据Credentials

Azure 自动化凭据具有类型 Microsoft.Automation/automationAccounts/credentials 和以下结构。Azure Automation credentials have a type of Microsoft.Automation/automationAccounts/credentials and have the following structure. 这包括常见变量和参数,以便可以将此代码片段复制并粘贴到解决方案文件,并更改参数名称。This includes common variables and parameters so that you can copy and paste this code snippet into your solution file and change the parameter names.

{
  "name": "[concat(parameters('accountName'), '/', variables('Credential').Name)]",
  "type": "Microsoft.Automation/automationAccounts/credentials",
  "apiVersion": "[variables('AutomationApiVersion')]",
  "location": "[parameters('regionId')]",
  "tags": { },
  "dependsOn": [
  ],
  "properties": {
    "userName": "[parameters('credentialUsername')]",
    "password": "[parameters('credentialPassword')]"
  }
}

下表介绍了凭据资源的属性。The properties for Credential resources are described in the following table.

属性Property 说明Description
userNameuserName 凭据的用户名。User name for the credential.
passwordpassword 凭据的密码。Password for the credential.

计划Schedules

Azure 自动化计划具有类型 Microsoft.Automation/automationAccounts/schedules 和以下结构。Azure Automation schedules have a type of Microsoft.Automation/automationAccounts/schedules and have the following structure. 这包括常见变量和参数,以便可以将此代码片段复制并粘贴到解决方案文件,并更改参数名称。This includes common variables and parameters so that you can copy and paste this code snippet into your solution file and change the parameter names.

{
  "name": "[concat(parameters('accountName'), '/', variables('Schedule').Name)]",
  "type": "microsoft.automation/automationAccounts/schedules",
  "apiVersion": "[variables('AutomationApiVersion')]",
  "tags": { },
  "dependsOn": [
  ],
  "properties": {
    "description": "[variables('Schedule').Description]",
    "startTime": "[parameters('scheduleStartTime')]",
    "timeZone": "[parameters('scheduleTimeZone')]",
    "isEnabled": "[variables('Schedule').IsEnabled]",
    "interval": "[variables('Schedule').Interval]",
    "frequency": "[variables('Schedule').Frequency]"
  }
}

下表介绍了计划资源的属性。The properties for schedule resources are described in the following table.

属性Property 说明Description
说明description 计划的可选说明。Optional description for the schedule.
startTimestartTime 指定计划的开始时间作为 DateTime 对象。Specifies the start time of a schedule as a DateTime object. 如果它可以转换为有效的 DateTime,则可以提供一个字符串。A string can be provided if it can be converted to a valid DateTime.
isEnabledisEnabled 指定是否启用计划。Specifies whether the schedule is enabled.
intervalinterval 计划的间隔类型。The type of interval for the schedule.

dayday
hourhour
frequencyfrequency 计划应在数天或数小时内触发的频率。Frequency that the schedule should fire in number of days or hours.

计划的开始时间值必须晚于当前时间。Schedules must have a start time with a value greater than the current time. 不能通过变量来提供此值,因为无法知道何时要安装。You cannot provide this value with a variable since you would have no way of knowing when it's going to be installed.

在解决方案中使用计划资源时,请使用以下两个策略之一。Use one of the following two strategies when using schedule resources in a solution.

  • 对计划的开始时间使用参数。Use a parameter for the start time of the schedule. 这会在安装解决方案时提示用户提供一个值。This will prompt the user to provide a value when they install the solution. 如果有多个计划,可以对多个计划使用单个参数值。If you have multiple schedules, you could use a single parameter value for more than one of them.
  • 可使用安装解决方案时启动的 runbook 创建计划。Create the schedules using a runbook that starts when the solution is installed. 这样用户将无需指定时间,但你不能在解决方案中包含计划,以免在删除解决方案时删除计划。This removes the requirement of the user to specify a time, but you can't contain the schedule in your solution so it will be removed when the solution is removed.

作业计划Job schedules

作业计划资源将 runbook 与一个计划链接。Job schedule resources link a runbook with a schedule. 作业计划资源具有 Microsoft.Automation/automationAccounts/jobSchedules 类型和以下结构。They have a type of Microsoft.Automation/automationAccounts/jobSchedules and have the following structure. 这包括常见变量和参数,以便可以将此代码片段复制并粘贴到解决方案文件,并更改参数名称。This includes common variables and parameters so that you can copy and paste this code snippet into your solution file and change the parameter names.

{
  "name": "[concat(parameters('accountName'), '/', variables('Schedule').LinkGuid)]",
  "type": "microsoft.automation/automationAccounts/jobSchedules",
  "apiVersion": "[variables('AutomationApiVersion')]",
  "location": "[parameters('regionId')]",
  "dependsOn": [
    "[resourceId('Microsoft.Automation/automationAccounts/runbooks/', parameters('accountName'), variables('Runbook').Name)]",
    "[resourceId('Microsoft.Automation/automationAccounts/schedules/', parameters('accountName'), variables('Schedule').Name)]"
  ],
  "tags": {
  },
  "properties": {
    "schedule": {
      "name": "[variables('Schedule').Name]"
    },
    "runbook": {
      "name": "[variables('Runbook').Name]"
    }
  }
}

下表介绍了作业计划的属性。The properties for job schedules are described in the following table.

属性Property 说明Description
计划名称schedule name 包含计划名称的单个 name 实体。Single name entity with the name of the schedule.
runbook 名称runbook name 包含 Runbook 名称的单个 name 实体。Single name entity with the name of the runbook.

变量Variables

Azure 自动化变量具有类型 Microsoft.Automation/automationAccounts/variables 和以下结构。Azure Automation variables have a type of Microsoft.Automation/automationAccounts/variables and have the following structure. 这包括常见变量和参数,以便可以将此代码片段复制并粘贴到解决方案文件,并更改参数名称。This includes common variables and parameters so that you can copy and paste this code snippet into your solution file and change the parameter names.

{
  "name": "[concat(parameters('accountName'), '/', variables('Variable').Name)]",
  "type": "microsoft.automation/automationAccounts/variables",
  "apiVersion": "[variables('AutomationApiVersion')]",
  "tags": { },
  "dependsOn": [
  ],
  "properties": {
    "description": "[variables('Variable').Description]",
    "isEncrypted": "[variables('Variable').Encrypted]",
    "type": "[variables('Variable').Type]",
    "value": "[variables('Variable').Value]"
  }
}

下表介绍了变量资源的属性。The properties for variable resources are described in the following table.

属性Property 说明Description
说明description 变量的可选说明。Optional description for the variable.
isEncryptedisEncrypted 指定是否应加密变量。Specifies whether the variable should be encrypted.
typetype 当前此属性无效。This property currently has no effect. 初始值决定该变量的数据类型。The data type of the variable will be determined by the initial value.
valuevalue 变量的值。Value for the variable.

备注

当前,“类型”属性对正在创建的变量无效。The type property currently has no effect on the variable being created. 变量的数据类型由值决定。The data type for the variable will be determined by the value.

如果设置变量的初始值,则该值必须配置为正确的数据类型。If you set the initial value for the variable, it must be configured as the correct data type. 下表提供了允许的不同数据类型及其语法。The following table provides the different data types allowable and their syntax. 请注意,JSON 中的值应始终使用引号括起来,任何特殊字符位于引号内。Note that values in JSON are expected to always be enclosed in quotes with any special characters within the quotes. 例如,字符串值应通过将字符串用引号括起来进行指定(使用转义字符 (\)),而数字值应使用一组引号进行指定。For example, a string value would be specified by quotes around the string (using the escape character (\)) while a numeric value would be specified with one set of quotes.

数据类型Data type 说明Description 示例Example 解析为Resolves to
字符串string 将值括在双引号中。Enclose value in double quotes. “"Hello world"”""Hello world"" “Hello world”"Hello world"
numericnumeric 用单引号将数字值括起来。Numeric value with single quotes. “64”"64" 6464
布尔值boolean 引号中的“true”或“false”。true or false in quotes. 请注意,此值必须为小写。Note that this value must be lowercase. "true""true" true
datetimedatetime 序列化日期值。Serialized date value.
可以在 PowerShell 中使用 ConvertTo-Json cmdlet 为特定日期生成此值。You can use the ConvertTo-Json cmdlet in PowerShell to generate this value for a particular date.
示例:get-date "5/24/2017 13:14:57" | ConvertTo-JsonExample: get-date "5/24/2017 13:14:57" | ConvertTo-Json
"\/Date(1495656897378)\/""\/Date(1495656897378)\/" 2017-05-24 13:14:572017-05-24 13:14:57

模块Modules

管理解决方案不需要定义 Runbook 使用的全局模块,因为它们始终都在自动化帐户中可用。Your management solution does not need to define global modules used by your runbooks because they will always be available in your Automation account. 需要包括 runbook 使用的任何其他模块资源。You do need to include a resource for any other module used by your runbooks.

集成模块具有类型 Microsoft.Automation/automationAccounts/modules 和以下结构。Integration modules have a type of Microsoft.Automation/automationAccounts/modules and have the following structure. 这包括常见变量和参数,以便可以将此代码片段复制并粘贴到解决方案文件,并更改参数名称。This includes common variables and parameters so that you can copy and paste this code snippet into your solution file and change the parameter names.

{
  "name": "[concat(parameters('accountName'), '/', variables('Module').Name)]",
  "type": "Microsoft.Automation/automationAccounts/modules",
  "apiVersion": "[variables('AutomationApiVersion')]",
  "dependsOn": [
  ],
  "properties": {
    "contentLink": {
      "uri": "[variables('Module').Uri]"
    }
  }
}

下表介绍了模块资源的属性。The properties for module resources are described in the following table.

属性Property 说明Description
contentLinkcontentLink 指定模块的内容。Specifies the content of the module.

uri - 模块内容的 URI。uri - Uri to the content of the module. 这会是 PowerShell 和脚本 Runbook 的 .ps1 文件,以及为图形 Runbook 导出的图形 Runbook 文件。This will be a .ps1 file for PowerShell and Script runbooks, and an exported graphical runbook file for a Graph runbook.
version - 自己跟踪的模块版本。version - Version of the module for your own tracking.

runbook 应依赖于模块资源,以确保模块资源在 runbook 之前创建。The runbook should depend on the module resource to ensure that it's created before the runbook.

更新模块Updating modules

如果更新的管理解决方案包含使用计划的 Runbook,并且新版本的解决方案具有该 Runbook 使用的新模块,则该 Runbook 可以使用旧版本的模块。If you update a management solution that includes a runbook that uses a schedule, and the new version of your solution has a new module used by that runbook, then the runbook may use the old version of the module. 应在解决方案中包括以下 Runbook,并创建一个作业,以在任何其他 Runbook 之前运行它们。You should include the following runbooks in your solution and create a job to run them before any other runbooks. 这会确保在加载 Runbook 之前视需要更新任何模块。This will ensure that any modules are updated as required before the runbooks are loaded.

示例Sample

以下是包含下列资源的解决方案示例:Following is a sample of a solution that include that includes the following resources:

  • Runbook。Runbook. 这是公共 GitHub 存储库中存储的示例 runbook。This is a sample runbook stored in a public GitHub repository.
  • 安装解决方案时启动 runbook 的自动化作业。Automation job that starts the runbook when the solution is installed.
  • 用于定期启动 runbook 的计划和作业计划。Schedule and job schedule to start the runbook at regular intervals.
  • 证书。Certificate.
  • 凭据。Credential.
  • 变量。Variable.
  • 模块。Module. 这是用于将数据写入到 Log Analytics 的 OMSIngestionAPI 模块This is the OMSIngestionAPI module for writing data to Log Analytics.

此示例使用的是解决方案中常用的标准解决方案参数变量,不同于资源定义中使用的硬编码值。The sample uses standard solution parameters variables that would commonly be used in a solution as opposed to hardcoding values in the resource definitions.

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "workspaceName": {
      "type": "string",
      "metadata": {
        "Description": "Name of Log Analytics workspace."
      }
    },
    "accountName": {
      "type": "string",
      "metadata": {
        "Description": "Name of Automation account."
      }
    },
    "workspaceregionId": {
      "type": "string",
      "metadata": {
        "Description": "Region of Log Analytics workspace."
      }
    },
    "regionId": {
      "type": "string",
      "metadata": {
        "Description": "Region of Automation account."
      }
    },
    "pricingTier": {
      "type": "string",
      "metadata": {
        "Description": "Pricing tier of both Log Analytics workspace and Azure Automation account."
      }
    },
    "certificateBase64Value": {
      "type": "string",
      "metadata": {
        "Description": "Base 64 value for certificate."
      }
    },
    "certificateThumbprint": {
      "type": "securestring",
      "metadata": {
        "Description": "Thumbprint for certificate."
      }
    },
    "credentialUsername": {
      "type": "string",
      "metadata": {
        "Description": "Username for credential."
      }
    },
    "credentialPassword": {
      "type": "securestring",
      "metadata": {
        "Description": "Password for credential."
      }
    },
    "scheduleStartTime": {
      "type": "string",
      "metadata": {
        "Description": "Start time for schedule."
      }
    },
    "scheduleTimeZone": {
      "type": "string",
      "metadata": {
        "Description": "Time zone for schedule."
      }
    },
    "scheduleLinkGuid": {
      "type": "string",
      "metadata": {
        "description": "GUID for the schedule link to runbook.",
        "control": "guid"
      }
    },
    "runbookJobGuid": {
      "type": "string",
      "metadata": {
        "description": "GUID for the runbook job.",
        "control": "guid"
      }
    }
  },
  "variables": {
    "SolutionName": "MySolution",
    "SolutionVersion": "1.0",
    "SolutionPublisher": "Contoso",
    "ProductName": "SampleSolution",

    "LogAnalyticsApiVersion": "2015-11-01-preview",
    "AutomationApiVersion": "2015-10-31",

    "Runbook": {
      "Name": "MyRunbook",
      "Description": "Sample runbook",
      "Type": "PowerShell",
      "Uri": "https://raw.githubusercontent.com/user/myrepo/master/samples/MyRunbook.ps1",
      "JobGuid": "[parameters('runbookJobGuid')]"
    },

    "Certificate": {
      "Name": "MyCertificate",
      "Base64Value": "[parameters('certificateBase64Value')]",
      "Thumbprint": "[parameters('certificateThumbprint')]"
    },

    "Credential": {
      "Name": "MyCredential",
      "UserName": "[parameters('credentialUsername')]",
      "Password": "[parameters('credentialPassword')]"
    },

    "Schedule": {
      "Name": "MySchedule",
      "Description": "Sample schedule",
      "IsEnabled": "true",
      "Interval": "1",
      "Frequency": "hour",
      "StartTime": "[parameters('scheduleStartTime')]",
      "TimeZone": "[parameters('scheduleTimeZone')]",
      "LinkGuid": "[parameters('scheduleLinkGuid')]"
    },

    "Variable": {
      "Name": "MyVariable",
      "Description": "Sample variable",
      "Encrypted": 0,
      "Type": "string",
      "Value": "'This is my string value.'"
    },

    "Module": {
      "Name": "OMSIngestionAPI",
      "Uri": "https://devopsgallerystorage.blob.core.chinacloudapi.cn/packages/omsingestionapi.1.3.0.nupkg"
    }
  },
  "resources": [
    {
      "name": "[concat(variables('SolutionName'), '[' ,parameters('workspacename'), ']')]",
      "location": "[parameters('workspaceRegionId')]",
      "tags": { },
      "type": "Microsoft.OperationsManagement/solutions",
      "apiVersion": "[variables('LogAnalyticsApiVersion')]",
      "dependsOn": [
        "[resourceId('Microsoft.Automation/automationAccounts/runbooks/', parameters('accountName'), variables('Runbook').Name)]",
        "[resourceId('Microsoft.Automation/automationAccounts/jobs/', parameters('accountName'), variables('Runbook').JobGuid)]",
        "[resourceId('Microsoft.Automation/automationAccounts/certificates/', parameters('accountName'), variables('Certificate').Name)]",
        "[resourceId('Microsoft.Automation/automationAccounts/credentials/', parameters('accountName'), variables('Credential').Name)]",
        "[resourceId('Microsoft.Automation/automationAccounts/schedules/', parameters('accountName'), variables('Schedule').Name)]",
        "[resourceId('Microsoft.Automation/automationAccounts/jobSchedules/', parameters('accountName'), variables('Schedule').LinkGuid)]",
        "[resourceId('Microsoft.Automation/automationAccounts/variables/', parameters('accountName'), variables('Variable').Name)]",
        "[resourceId('Microsoft.Automation/automationAccounts/modules/', parameters('accountName'), variables('Module').Name)]"
      ],
      "properties": {
        "workspaceResourceId": "[resourceId('Microsoft.OperationalInsights/workspaces', parameters('workspacename'))]",
        "referencedResources": [
          "[resourceId('Microsoft.Automation/automationAccounts/modules/', parameters('accountName'), variables('Module').Name)]"
        ],
        "containedResources": [
          "[resourceId('Microsoft.Automation/automationAccounts/runbooks/', parameters('accountName'), variables('Runbook').Name)]",
          "[resourceId('Microsoft.Automation/automationAccounts/jobs/', parameters('accountName'), variables('Runbook').JobGuid)]",
          "[resourceId('Microsoft.Automation/automationAccounts/certificates/', parameters('accountName'), variables('Certificate').Name)]",
          "[resourceId('Microsoft.Automation/automationAccounts/credentials/', parameters('accountName'), variables('Credential').Name)]",
          "[resourceId('Microsoft.Automation/automationAccounts/schedules/', parameters('accountName'), variables('Schedule').Name)]",
          "[resourceId('Microsoft.Automation/automationAccounts/jobSchedules/', parameters('accountName'), variables('Schedule').LinkGuid)]",
          "[resourceId('Microsoft.Automation/automationAccounts/variables/', parameters('accountName'), variables('Variable').Name)]"
        ]
      },
      "plan": {
        "name": "[concat(variables('SolutionName'), '[' ,parameters('workspaceName'), ']')]",
        "Version": "[variables('SolutionVersion')]",
        "product": "[variables('ProductName')]",
        "publisher": "[variables('SolutionPublisher')]",
        "promotionCode": ""
      }
    },
    {
      "name": "[concat(parameters('accountName'), '/', variables('Runbook').Name)]",
      "type": "Microsoft.Automation/automationAccounts/runbooks",
      "apiVersion": "[variables('AutomationApiVersion')]",
      "dependsOn": [
      ],
      "location": "[parameters('regionId')]",
      "tags": { },
      "properties": {
        "runbookType": "[variables('Runbook').Type]",
        "logProgress": "true",
        "logVerbose": "true",
        "description": "[variables('Runbook').Description]",
        "publishContentLink": {
          "uri": "[variables('Runbook').Uri]",
          "version": "1.0.0.0"
        }
      }
    },
    {
      "name": "[concat(parameters('accountName'), '/', variables('Runbook').JobGuid)]",
      "type": "Microsoft.Automation/automationAccounts/jobs",
      "apiVersion": "[variables('AutomationApiVersion')]",
      "location": "[parameters('regionId')]",
      "dependsOn": [
        "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'), '/runbooks/', variables('Runbook').Name)]"
      ],
      "tags": { },
      "properties": {
        "runbook": {
          "name": "[variables('Runbook').Name]"
        },
        "parameters": {
          "targetSubscriptionId": "[subscription().subscriptionId]",
          "resourcegroup": "[resourceGroup().name]",
          "automationaccount": "[parameters('accountName')]"
        }
      }
    },
    {
      "name": "[concat(parameters('accountName'), '/', variables('Certificate').Name)]",
      "type": "Microsoft.Automation/automationAccounts/certificates",
      "apiVersion": "[variables('AutomationApiVersion')]",
      "location": "[parameters('regionId')]",
      "tags": { },
      "dependsOn": [
      ],
      "properties": {
        "Base64Value": "[variables('Certificate').Base64Value]",
        "Thumbprint": "[variables('Certificate').Thumbprint]"
      }
    },
    {
      "name": "[concat(parameters('accountName'), '/', variables('Credential').Name)]",
      "type": "Microsoft.Automation/automationAccounts/credentials",
      "apiVersion": "[variables('AutomationApiVersion')]",
      "location": "[parameters('regionId')]",
      "tags": { },
      "dependsOn": [
      ],
      "properties": {
        "userName": "[variables('Credential').UserName]",
        "password": "[variables('Credential').Password]"
      }
    },
    {
      "name": "[concat(parameters('accountName'), '/', variables('Schedule').Name)]",
      "type": "microsoft.automation/automationAccounts/schedules",
      "apiVersion": "[variables('AutomationApiVersion')]",
      "tags": { },
      "dependsOn": [
      ],
      "properties": {
        "description": "[variables('Schedule').Description]",
        "startTime": "[variables('Schedule').StartTime]",
        "timeZone": "[variables('Schedule').TimeZone]",
        "isEnabled": "[variables('Schedule').IsEnabled]",
        "interval": "[variables('Schedule').Interval]",
        "frequency": "[variables('Schedule').Frequency]"
      }
    },
    {
      "name": "[concat(parameters('accountName'), '/', variables('Schedule').LinkGuid)]",
      "type": "microsoft.automation/automationAccounts/jobSchedules",
      "apiVersion": "[variables('AutomationApiVersion')]",
      "location": "[parameters('regionId')]",
      "dependsOn": [
        "[resourceId('Microsoft.Automation/automationAccounts/runbooks/', parameters('accountName'), variables('Runbook').Name)]",
        "[resourceId('Microsoft.Automation/automationAccounts/schedules/', parameters('accountName'), variables('Schedule').Name)]"
      ],
      "tags": {
      },
      "properties": {
        "schedule": {
          "name": "[variables('Schedule').Name]"
        },
        "runbook": {
          "name": "[variables('Runbook').Name]"
        }
      }
    },
    {
      "name": "[concat(parameters('accountName'), '/', variables('Variable').Name)]",
      "type": "microsoft.automation/automationAccounts/variables",
      "apiVersion": "[variables('AutomationApiVersion')]",
      "tags": { },
      "dependsOn": [
      ],
      "properties": {
        "description": "[variables('Variable').Description]",
        "isEncrypted": "[variables('Variable').Encrypted]",
        "type": "[variables('Variable').Type]",
        "value": "[variables('Variable').Value]"
      }
    },
    {
      "name": "[concat(parameters('accountName'), '/', variables('Module').Name)]",
      "type": "Microsoft.Automation/automationAccounts/modules",
      "apiVersion": "[variables('AutomationApiVersion')]",
      "dependsOn": [
      ],
      "properties": {
        "contentLink": {
          "uri": "[variables('Module').Uri]"
        }
      }
    }

  ],
  "outputs": { }
}

后续步骤Next steps