Have you correctly licensed your migrated SQL Server VMs in Azure?

Are you migrating SQL Server virtual machines to Azure? If so, how are you handling the SQL licensing once migrated? If you are running SQL Server Standard or Enterprise edition then you need to have either an active software assurance agreement or a current CSP subscription for SQL Server in order to qualify for license mobility and utilise something called Azure Hybrid Use Benefit.

Essentially, this means you don’t need to re-license to run the SQL workload in Azure.

Am I not licensed already?

If you don’t have software assurance (and most customers don’t) or a CSP subscription for SQL Server (again, this is rare) then you are not licensed for running SQL Server in Azure and you need to re-license. This can be done in two ways:

AHUB – Azure Hybrid Use Benefit – This is bring your own license, i.e. purchasing the new SQL Server licenses upfront by one of the methods I mentioned already

or

PAYG – Pay As You Go – paying for the licenses on a per minute consumption basis on Azure

The SQL VM Resource Provider

When you deploy a virtual machine with a SQL Server image from the Azure marketplace, it will automatically register with the SQL VM resource provider. This creates a new resource in the Azure resource manager that you can access and configure various features such as: license type, storage configuration, automated patching, automated backup etc.

When migrating a SQL Server virtual machine into Azure this resource is not created for you, likewise if you decide to install SQL Server yourself on an Azure virtual machine again this resource is not created.

Instead, you will have to register your virtual machine with the SQL VM resource provider. This will unlock these feature configuration benefits as well as allow you a way to simplify the license management.

In the case of migration of a SQL Server virtual machine without software assurance into Azure you need to decide how to re-license as outlined above. This method is specified when registering the virtual machine with the resource provider and if you wish, can be changed in future.

The important thing is that you must remember to re-license non-compliant SQL Server workloads for Azure where required. Otherwise, you are in breach of Microsoft license compliance and at risk of a heavy fine.

The Process

The process is thankfully quite straightforward. As a pre-requisite for migrated/uploaded images you should make sure to install the Azure virtual machine agent extension. This is required as the resource provider registration step coming up will need to use this to install another extension called ‘SQLIaasExtension’.

The Azure VM extension can be installed as outlined here: https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/agent-windows

Once this extension is installed then you can register with the resource provider.

You have a few choices with the parameters here.

You will need to specify the license type as either AHUB or PAYG. So if you are migrating and don’t have an existing valid license this should be set to PAYG. Remember, this can always be changed later.

There is a third option here which is DR. This is a free license where your SQL Server is being used for disaster recovery only and only applies where you have a valid license that allows you to utilise Azure Hybrid Use Benefit.

Secondly you have two management options: Lightweight or Full.

Lightweight will register your virtual machine with the resource provider and give you basic visibility over the service but will not unlock any of the management features mentioned previously. Importantly, this step does not require any restarts of the SQL Server service.

Instead you can choose Full, which will unlock all of the features but note this does require a restart of the SQL Server service.

If you choose the Lightweight option then you can upgrade to Full at a later stage.

Below are the PowerShell commands required and the process is fairly quick, but will take a few minutes to run.

Tip: If the process is taking a long time and eventually times out then it is likely that your Azure VM agent is not installed or not working correctly.

# Register the SQL VM resource provider to your subscription
Register-AzResourceProvider -ProviderNamespace Microsoft.SqlVirtualMachine

# Get the existing compute VM
$vm = Get-AzVM -Name <vm_name> -ResourceGroupName <resource_group_name>
        
# Register SQL VM with 'Full' SQL IaaS agent
New-AzSqlVM -Name $vm.Name -ResourceGroupName $vm.ResourceGroupName -Location $vm.Location `
  -LicenseType PAYG -SqlManagementType Full

The Result

Once registered, you will see a new SQL VM resource in your resource group and after a few minutes the SQLIaasExtension should start reporting back details of your SQL environment.

From here you can start configuring the various management features of your SQL Server Virtual Machine. This also completes the licensing process so if you have registered as PAYG then you will be licensed and billed for SQL Server on a per minute allocated basis.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.