Register Windows SQL Server VM with SQL IaaS Agent extension

Applies to: SQL Server on Azure VM

Register your SQL Server VM with the SQL IaaS Agent extension to unlock a wealth of feature benefits for your SQL Server on Azure Windows VM.

This article teaches you to register a single SQL Server VM with the SQL IaaS Agent extension. Alternatively, you can register all SQL Server VMs in a subscription automatically or multiple VMs in bulk using a script.

Note

SQL Server VMs deployed via the Azure marketplace after October 2022 have the least privileged model enabled by default. Management modes for the SQL IaaS Agent extension were removed in March 2023.

Overview

Registering with the SQL Server IaaS Agent extension creates the SQL virtual machine resource within your subscription, which is a separate resource from the virtual machine resource. Deleting the extension from your SQL Server VM removes the SQL virtual machine resource but doesn't drop the actual virtual machine.

Deploying a SQL Server VM Azure Marketplace image through the Azure portal automatically registers the SQL Server VM with the extension. However, if you choose to self-install SQL Server on an Azure virtual machine, or provision an Azure virtual machine from a custom VHD, then you must register your SQL Server VM with the SQL IaaS Agent extension to unlock full feature benefits and manageability. By default, Azure VMs that have SQL Server 2016 or later installed will be automatically registered with the SQL IaaS Agent extension when detected by the CEIP service. See the SQL Server privacy supplement for more information. For information about privacy, see the SQL IaaS Agent extension privacy statements.

To utilize the SQL IaaS Agent extension, you must first register your subscription with the Microsoft.SqlVirtualMachine provider, which gives the SQL IaaS Agent extension the ability to create resources within that specific subscription. Then you can register your SQL Server VM with the extension.

Prerequisites

To register your SQL Server VM with the extension, you'll need the following:

Register subscription with RP

To register your SQL Server VM with the SQL IaaS Agent extension, you must first register your subscription with the Microsoft.SqlVirtualMachine resource provider (RP). This gives the SQL IaaS Agent extension the ability to create resources within your subscription. You can do so by using the Azure portal, the Azure CLI, or Azure PowerShell.

Register your subscription with the resource provider by using the Azure CLI:

# Register the SQL IaaS Agent extension to your subscription
az provider register --namespace Microsoft.SqlVirtualMachine

Register with extension

You can manually register your SQL Server VM with the SQL IaaS Agent extension by using Azure PowerShell or the Azure CLI.

Provide the SQL Server license type as either pay-as-you-go (PAYG) to pay per usage, Azure Hybrid Benefit (AHUB) to use your own license, or disaster recovery (DR) to activate the free DR replica license.

Register a SQL Server with the Azure CLI:

# Register SQL Server VM with the extension
az sql vm create --name <vm_name> --resource-group <resource_group_name> --location <vm_location> --license-type <license_type>

Verify registration status

You can verify if your SQL Server VM has already been registered with the SQL IaaS Agent extension by using the Azure portal, the Azure CLI, or Azure PowerShell.

Verify current SQL Server VM registration status by using the Azure CLI. ProvisioningState shows as Succeeded if registration was successful.

az sql vm show -n <vm_name> -g <resource_group>

An error indicates that the SQL Server VM hasn't been registered with the extension.

Delete the extension

To unregister your SQL Server VM with the SQL IaaS Agent extension, delete the SQL virtual machine resource by using the Azure portal, PowerShell, or the Azure CLI. Deleting the SQL virtual machine resource doesn't delete the SQL Server VM.

Warning

Use extreme caution when deleting the extension from your SQL Server VM. Follow the steps carefully because it is possible to inadvertently delete the virtual machine when attempting to remove the resource.

To delete the extension from your SQL Server VM with the Azure CLI, use the az sql vm delete command. This removes the SQL Server VM resource but doesn't delete the virtual machine.

To delete the extension from your SQL Server VM with the Azure CLI, use the following sample command:

az sql vm delete
  --name <SQL VM resource name> |
  --resource-group <Resource group name> |
  --yes

To learn more, review the following articles: