Automate management tasks on Azure virtual machines by using the SQL Server IaaS Agent Extension

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.

Note

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.

To view the classic version of this article, see SQL Server IaaS Agent Extension for SQL Server VMs (classic).

Supported services

The SQL Server IaaS Agent Extension supports the following administration tasks:

Administration feature Description
SQL Server automated backup 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. For more information, see Automated backup for SQL Server in Azure virtual machines (Resource Manager).
SQL Server automated patching 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. For more information, see Automated patching for SQL Server in Azure virtual machines (Resource Manager).
Azure Key Vault integration Enables you to automatically install and configure Azure Key Vault on your SQL Server VM. For more information, see Configure Azure Key Vault integration for SQL Server on Azure Virtual Machines (Resource Manager).

After the SQL Server Iaas Agent Extension is installed and running, it makes the administration features available:

  • On the SQL Server panel of the virtual machine in the Azure portal and through Azure PowerShell for SQL Server images on Azure Marketplace.
  • Through Azure PowerShell for manual installations of the extension.

Prerequisites

Here are the requirements to use the SQL Server IaaS Agent Extension on your VM:

Operating system:

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

SQL Server version:

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

Azure PowerShell:

Note

This article has been updated to use the new Azure PowerShell Az module. You can still use the AzureRM module, which will continue to receive bug fixes until at least December 2020. To learn more about the new Az module and AzureRM compatibility, see Introducing the new Azure PowerShell Az module. For Az module installation instructions, see Install Azure PowerShell.

Installation

The SQL Server IaaS extension is installed when you register your SQL Server VM with the SQL VM resource provider. If necessary, you can install the SQL Server IaaS agent manually using the below PowerShell command:

  Set-AzVMExtension -ResourceGroupName "<ResourceGroupName>" `
  -Location "<VMLocation>" -VMName "<VMName>" `
  -Name "SqlIaasExtension" -Publisher "Microsoft.SqlServer.Management" `
  -ExtensionType "SqlIaaSAgent" -TypeHandlerVersion "2.0";  

Note

Installing the extension restarts the SQL Server service.

Install on a VM with a single named SQL Server instance

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.

To use a named instance of SQL Server, follow these steps:

  1. Deploy a SQL Server VM from Azure Marketplace.
  2. Uninstall the IaaS extension from the Azure portal.
  3. Uninstall SQL Server completely within the SQL Server VM.
  4. Install SQL Server with a named instance within the SQL Server VM.
  5. Install the IaaS extension from the Azure portal.

Get the status of the SQL Server IaaS extension

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. You should see the SqlIaasExtension extension listed.

Status of the SQL Server IaaS Agent Extension in the Azure portal

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

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.

Uninstalling the SQL Server IaaS Agent Extension in Azure portal

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.

For more information about running SQL Server on Azure Virtual Machines, see the What is SQL Server on Azure Virtual Machines?.