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

自动载入Automate onboarding

若要提高部署 Azure 服务器管理服务的效率,请考虑在本指南的前面部分中讨论的自动部署。To improve the efficiency of deploying Azure server management services, consider automating deployment as discussed in previous sections of this guidance. 以下部分中提供的脚本和示例模板是用于开发自己的载入过程自动化的起点。The script and the example templates provided in the following sections are starting points for developing your own automation of onboarding processes.

示例代码的 GitHub 存储库支持此指南。This guidance is supported by a GitHub repository of sample code. 存储库提供示例脚本和 Azure 资源管理器模板,可帮助你自动部署 Azure 服务器管理服务。The repository provides example scripts and Azure Resource Manager templates to help you automate the deployment of Azure server management services.

示例文件演示如何使用 Azure PowerShell cmdlet 自动执行以下任务:The sample files illustrate how to use Azure PowerShell cmdlets to automate the following tasks:

  • 创建 Log Analytics 工作区Create a Log Analytics workspace. (或,如果工作区满足要求,请使用现有工作区。(Or, use an existing workspace if it meets the requirements. 有关详细信息,请参阅 工作区计划For details, see Workspace planning.

  • 创建自动化帐户,或使用满足要求的现有帐户。Create an Automation account, or use an existing account that meets the requirements. 有关详细信息,请参阅 工作区计划For more information, see Workspace planning.

  • 链接自动化帐户和 Log Analytics 工作区。Link the Automation account and the Log Analytics workspace. 如果使用 Azure 门户进行载入,则不需要执行此步骤。This step isn't required if you're onboarding by using the Azure portal.

  • 启用工作区的更新管理解决方案和更改跟踪和清单解决方案。Enable the Update Management solution and the Change Tracking and Inventory solution for the workspace.

  • 使用 Azure 策略加入 Azure Vm。Onboard Azure VMs by using Azure Policy. 策略在 Azure Vm 上安装 Log Analytics 代理和 Microsoft Dependency Agent。A policy installs the Log Analytics agent and the Microsoft Dependency Agent on the Azure VMs.

  • 使用Azure 策略为 vm 自动启用 azure 备份Auto-enable Azure Backup for VMs using Azure Policy

  • 通过在本地服务器上安装 Log Analytics 代理来将其载入。Onboard on-premises servers by installing the Log Analytics agent on them.

本示例使用下表中所述的文件。The files described in the following table are used in this sample. 你可以对其进行自定义以支持你自己的部署方案。You can customize them to support your own deployment scenarios.

文件名File name 说明Description
New-AMSDeployment.ps1 用于实现自动载入的主协调脚本。The main, orchestrating script that automates onboarding. 它将创建资源组、位置、工作区和自动化帐户(如果它们尚不存在)。It creates resource groups, and location, workspace, and Automation accounts, if they don't exist already. 此 PowerShell 脚本需要现有的订阅。This PowerShell script requires an existing subscription.
Workspace-AutomationAccount.json 部署工作区和自动化帐户资源的资源管理器模板。A Resource Manager template that deploys the workspace and Automation account resources.
WorkspaceSolutions.json 资源管理器模板,用于在 Log Analytics 工作区中启用所需的解决方案。A Resource Manager template that enables the solutions you want in the Log Analytics workspace.
ScopeConfig.json 一个资源管理器模板,该模板使用更改跟踪和清单解决方案的本地服务器的选择模型。A Resource Manager template that uses the opt-in model for on-premises servers with the Change Tracking and Inventory solution. 使用选择模型是可选的。Using the opt-in model is optional.
Enable-VMInsightsPerfCounters.ps1 一个 PowerShell 脚本,它启用用于 VM 的 Azure Monitor 并配置性能计数器。A PowerShell script that enables Azure Monitor for VMs and configures performance counters.
ChangeTracking-FileList.json 一个资源管理器模板,用于定义将由更改跟踪监视的文件的列表。A Resource Manager template that defines the list of files that will be monitored by change tracking.

使用以下命令运行 New-AMSDeployment.ps1Use the following command to run New-AMSDeployment.ps1:

.\New-AMSDeployment.ps1 -SubscriptionName '{Subscription Name}' -WorkspaceName '{Workspace Name}' -WorkspaceLocation '{Azure Location}' -AutomationAccountName {Account Name} -AutomationAccountLocation {Account Location}

后续步骤Next steps

了解如何设置基本警报,以通知团队关键管理事件和问题。Learn how to set up basic alerts to notify your team of key management events and issues.