使用 SQL Server IaaS 代理扩展在 Azure 虚拟机上自动完成管理任务Automate management tasks on Azure virtual machines by using the SQL Server IaaS Agent Extension

适用于:是Azure VM 上的 SQL ServerAPPLIES TO: yesSQL Server on Azure VM

SQL Server IaaS 代理扩展 (SqlIaasExtension) 在 Azure 虚拟机上运行,以自动执行管理任务。The SQL Server IaaS Agent Extension (SqlIaasExtension) runs on Azure virtual machines to automate administration tasks. 本文概述了该扩展支持的服务概述。This article provides an overview of the services that the extension supports. 本文还提供了有关安装、状态和删除扩展的说明。This article also provides instructions for installation, status, and removal of the extension.

备注

Azure 提供了可以用来创建和处理资源的两个不同部署模型:Azure 资源管理器部署模型和经典部署模型Azure has two different deployment models you can use to create and work with resources: Azure Resource Manager and classic. 本文介绍了资源管理器部署模型的使用。This article covers the use of the Resource Manager deployment model. 对于新部署,建议使用资源管理器部署模型而非经典部署模型。We recommend the Resource Manager deployment model for new deployments instead of the classic deployment model.

若要查看这篇文章的经典版,请参阅适用于 SQL Server VM(经典)的 SQL Server 代理扩展To view the classic version of this article, see SQL Server IaaS Agent Extension for SQL Server VMs (classic).

支持的服务Supported services

SQL Server IaaS 代理扩展支持以下管理任务:The SQL Server IaaS Agent Extension supports the following administration tasks:

管理功能Administration feature 说明Description
SQL Server 自动备份SQL Server automated backup 对 VM 中的 SQL Server 默认实例或已正确安装的命名实例自动执行所有数据库的备份计划。Automates the scheduling of backups for all databases for either the default instance or a properly installed named instance of SQL Server on the VM. 有关详细信息,请参阅 Azure 虚拟机中 SQL Server 的自动备份 (Resource Manager)For more information, see Automated backup for SQL Server in Azure virtual machines (Resource Manager).
SQL Server 自动修补SQL Server automated patching 配置维护时段,可在此时段对 VM 进行重要的 Windows 更新,避开工作负荷的高峰期。Configures a maintenance window during which important Windows updates to your VM can take place, so you can avoid updates during peak times for your workload. 有关详细信息,请参阅 Azure 虚拟机中 SQL Server 的自动修补 (Resource Manager)For more information, see Automated patching for SQL Server in Azure virtual machines (Resource Manager).
Azure 密钥保管库集成Azure Key Vault integration 可让你在 SQL Server VM 上自动安装和配置 Azure 密钥保管库。Enables you to automatically install and configure Azure Key Vault on your SQL Server VM. 有关详细信息,请参阅 为 Azure 虚拟机上的 SQL Server 配置 Azure 密钥保管库集成 (Resource Manager)For more information, see Configure Azure Key Vault integration for SQL Server on Azure Virtual Machines (Resource Manager).

安装并运行 SQL Server Iaas 代理扩展后,它将使管理功能可用:After the SQL Server Iaas Agent Extension is installed and running, it makes the administration features available:

  • 在 Azure 门户的虚拟机的 SQL Server 面板中,通过 Azure 市场上 SQL Server 映像的 Azure PowerShell。On the SQL Server panel of the virtual machine in the Azure portal and through Azure PowerShell for SQL Server images on Azure Marketplace.
  • 通过 Azure PowerShell 手动安装扩展。Through Azure PowerShell for manual installations of the extension.

先决条件Prerequisites

下面是在 VM 上使用 SQL Server IaaS 代理扩展的要求:Here are the requirements to use the SQL Server IaaS Agent Extension on your VM:

操作系统Operating system:

  • Windows Server 2008 R2Windows Server 2008 R2
  • Windows Server 2012Windows Server 2012
  • Windows Server 2012 R2Windows Server 2012 R2
  • Windows Server 2016Windows Server 2016
  • Windows Server 2019Windows Server 2019

SQL Server 版本SQL Server version:

  • SQL Server 2008SQL Server 2008
  • SQL Server 2008 R2SQL Server 2008 R2
  • SQL Server 2012SQL Server 2012
  • SQL Server 2014SQL Server 2014
  • SQL Server 2016SQL Server 2016
  • SQL Server 2017SQL Server 2017
  • SQL Server 2019SQL Server 2019

Azure PowerShellAzure PowerShell:

备注

本文进行了更新,以便使用新的 Azure PowerShell Az 模块。This article has been updated to use the new Azure PowerShell Az module. 你仍然可以使用 AzureRM 模块,至少在 2020 年 12 月之前,它将继续接收 bug 修补程序。You can still use the AzureRM module, which will continue to receive bug fixes until at least December 2020. 若要详细了解新的 Az 模块和 AzureRM 兼容性,请参阅新 Azure Powershell Az 模块简介To learn more about the new Az module and AzureRM compatibility, see Introducing the new Azure PowerShell Az module. 有关 Az 模块安装说明,请参阅安装 Azure PowerShellFor Az module installation instructions, see Install Azure PowerShell.

安装Installation

使用 Azure 门户预配某个 SQL Server 虚拟机 Azure 市场映像时,会自动安装 SQL Server IaaS 扩展。The SQL Server IaaS extension is automatically installed when you provision one of the SQL Server virtual machine Azure Marketplace images by using the Azure portal. 如果需要,可以使用以下 PowerShell 命令手动安装 SQL Server IaaS 代理:If necessary, you can install the SQL Server IaaS agent manually using the below PowerShell command:

Set-AzVMSqlServerExtension -VMName "sql2017" `
-ResourceGroupName "LabsqlIAASagent" -Name "SQLIaasExtension" `
-Version "2.0" -Location "China North";  

备注

安装扩展会重新启动 SQL Server 服务。Installing the extension restarts the SQL Server service.

在具有单个命名 SQL Server 实例的 VM 上安装Install on a VM with a single named SQL Server instance

如果卸载了默认实例并且重新安装了 IaaS 扩展,则 SQL Server IaaS 扩展将与 SQL Server 上的命名实例一起使用。The SQL Server IaaS extension will work with a named instance on SQL Server if the default instance is uninstalled and the IaaS extension is reinstalled.

若要使用 SQL Server 的命名实例,请执行以下步骤:To use a named instance of SQL Server, follow these steps:

  1. 从 Azure 市场部署 SQL Server VM。Deploy a SQL Server VM from Azure Marketplace.
  2. Azure 门户中卸载 IaaS 扩展。Uninstall the IaaS extension from the Azure portal.
  3. 完全卸载 SQL Server VM 中的 SQL Server。Uninstall SQL Server completely within the SQL Server VM.
  4. 在 SQL Server VM 中将 SQL Server 与命名实例一起安装。Install SQL Server with a named instance within the SQL Server VM.
  5. 使用 powershell 脚本安装 IaaS 扩展。Install the IaaS extension with powershell scripts.

获取 SQL Server IaaS 扩展的状态Get the status of the SQL Server IaaS extension

验证是否已安装扩展的方法之一是在 Azure 门户中查看代理状态。One way to verify that the extension is installed is to view the agent status in the Azure portal. 在虚拟机窗口中选择“所有设置”,然后选择“扩展”。 Select All settings in the virtual machine window, and then select Extensions. 应看到列出“SqlIaasExtension”扩展。You should see the SqlIaasExtension extension listed.

Azure 门户中 SQL Server IaaS 代理扩展的状态

也可以使用 Get-AzVMSqlServerExtension Azure PowerShell cmdlet:You can also use the Get-AzVMSqlServerExtension Azure PowerShell cmdlet:

Get-AzVMSqlServerExtension -VMName "vmname" -ResourceGroupName "resourcegroupname"

上一个命令确认已安装代理并提供常规状态信息。The previous command confirms that the agent is installed and provides general status information. 还可使用以下命令获取有关自动备份和修补的特定状态信息:You can get specific status information about automated backup and patching by using the following commands:

$sqlext = Get-AzVMSqlServerExtension -VMName "vmname" -ResourceGroupName "resourcegroupname"
$sqlext.AutoPatchingSettings
$sqlext.AutoBackupSettings

删除Removal

在 Azure 门户中,可以通过选择虚拟机属性的“扩展”窗口中的省略号来卸载扩展。In the Azure portal, you can uninstall the extension by selecting the ellipsis in the Extensions window of your virtual machine properties. 然后选择“删除”。Then select Delete.

在 Azure 门户中卸载 SQL Server IaaS 代理扩展

也可以使用 Remove-AzVMSqlServerExtension PowerShell cmdlet:You can also use the Remove-AzVMSqlServerExtension PowerShell cmdlet:

Remove-AzVMSqlServerExtension -ResourceGroupName "resourcegroupname" -VMName "vmname" -Name "SqlIaasExtension"

后续步骤Next steps

开始使用扩展支持的服务之一。Begin using one of the services that the extension supports. 有关信息,请参阅本文的支持的服务部分中提到的文章。For more information, see the articles referenced in the Supported services section of this article.

有关在 Azure 虚拟机中运行 SQL Server 的详细信息,请参阅什么是 Azure 虚拟机中的 SQL Server?For more information about running SQL Server on Azure Virtual Machines, see the What is SQL Server on Azure Virtual Machines?.