Please note, this post has been updated by replacing the Azure PowerShell examples with recently published Azure SQL VM CLI.
Azure Hybrid Benefit (AHB) for SQL Server allows you to use on-premises licenses to run SQL Server on Azure Virtual Machines. If you have Software Assurance, you can use AHB when deploying a new SQL VM or activate SQL Server AHB for an existing SQL VM with a pay as you go (PAYG) license. Bring your own license (BYOL) SQL Images on Azure Marketplace should be used to implement SQL Server AHB when deploying a new SQL VM. However, if you already have a SQL VM with a PAYG license, activating AHB currently requires re-deploying the VM with BYOL SQL image.
Today, we are revealing a new, simple way to activate SQL Server AHB on Azure VM with SQL VM Resource Provider. SQL VM resource provider is a new Azure resource provider, Microsoft. SqlVirtualMachine, that supplies SQL Server configurations for an Azure VM as a resource that can be deployed and managed through Azure Resource Manager. This new infrastructure brings a backend management service for SQL Server on Azure VM including dynamic updates of SQL Server settings such as license type. To activate SQL Server AHB for an existing PAYG SQL VM, simply create a Microsoft. SqlVirtualMachine/SqlVirtualMachine type resource for the existing VM by providing the VM's resource ID and setting SqlServerLicenseType as “AHUB.”
First of all, you should register your subscription with Microsoft. SqlVirtualMachine provider by running the following Azure CLI command or register through Azure Portal to create SqlVirtualMachine type resources:
// Register subscription with SQL VM RP az provider register --namespace Microsoft.SqlVirtualMachine --subscription <subscription name>
Then, install or update Azure CLI by downloading the MSI package to get access to Azure SQL VM CLI.
Below is Azure SQL VM Create CLI command to activate AHB for existing PAYG SQL VM:
// Create an AHUB SqlVm az sql vm create -n <VM Name> -g <Resource Group Name> -l <Location> --license-type AHUB EX: az sql vm create -n sqlvm -g myresourcegroup -l eastus --license-type AHUB
If you have not set SqlServerLicenseType property while creating SqlVirtualMachine resource, then the SqlServerLicenseType will be set as “PAYG” by default. At any time, you can update the SqlServerLicenseType property as “AHUB” to activate SQL Server AHB if you have Software Assurance with the following Azure SQL VM Update CLI command:
// Update SqlVirtualMachine SqlServerLicenseType property az sql vm update -n <VM Name> -g <Resource Group Name> --license-type AHUB EX: az sql vm update -n sqlvm -g myresourcegroup --license-type AHUB
If you have recently created your SQL VM through Azure Portal or if you updated any SQL Configuration for an existing SQL VM through Azure Portal then your SQL VM is already registered with SQL VM RP. In this case, you should only run the Azure SQL VM Update CLI command to update the license type from PAYG to AHUB. If the original VM was created from PAYG SQL Server image on Azure Marketplace, then you can update the license type to AHUB and back to PAYG any time without any limitation. If the original VM is not created from a PAYG SQL Server image but SQL Server was self-installed or deployed from a BYOL SQL Server image, then you cannot convert the license type to PAYG.
New SqlVirtualMachine resource links to the existing VM resource; this has no impact on the existing VM resources. SqlVirtualMachine resource will manage the metadata about SQL Server settings by reading them from SQL IaaS Extension properties. If the VM is deleted, this notifies the linked SqlVirtualMachine resource, which also gets deleted asynchronously. SqlVirtualMachine resource can be deleted independently, by keeping the VM resource. However, SQL Server license changes fall back to the original state in this case.
No VM restart
Activating SQL Server AHB for a PAYG SQL VM does not restart the VM, and it does not impact any of the existing resources. It only updates the metadata representing the SQL Server license type which defines the bill for the VM resource.
No additional cost
SqlVirtualMachine resource manages all existing SQL Server configurations available today, including automated backup, patching, Azure Key Vault Integration and storage configuration, and also new “SqlServerLicenseType.” The additional resource and enhanced manageability have no additional cost.
Billing for an Azure resource is generated by multiplying the per-second cost of each resource with the used seconds in an hour. The SQL Server license cost will be removed from the bill of the VM resource immediately after the SQL Server license type is updated as “AHUB.” You can verify the changes in the daily Azure bill. To deactivate SQL Server AHB, simply run the same update command by setting SQL Server License type as PAYG. The per-second SQL Server license cost will be added to the VM bill immediately after the new command is executed.
One solution for all subscription types
Customers with Software Assurance have SQL Server AHB rights independent of the subscription type. Older solutions for activating SQL Server AHB on Azure VM based on BYOL SQL images were only available for EA customers, but the new solution described above is applicable to all subscriptions with Software Assurance.
With new Microsoft. SqlVirtualMachine resource provider you can manage SQL server configurations on Azure VMs dynamically. Flexible SQL Server License type configuration is the first feature we are delivering with SQL VM resource provider, and it enables instant and significant cost savings for SQL VM.