Bulk Register with SQL VM Resource Provider
Published Oct 25 2019 10:35 AM 5,214 Views
Microsoft

Many of you are running workloads on SQL Server on Azure Virtual Machines (SQL VM) today to leverage cloud agility, elasticity and scalability benefits. SQL VM differentiates by allowing full control on the OS, VM size, storage subsystem and offering free manageability services.  

 

If you choose to self-install SQL Server on Azure Virtual Machines instead of choosing a preconfigured SQL Server image from Azure Marketplace, you should register with SQL VM Resource Provider (SQL VM RP) for cost savings with simplified license management and free SQL Server manageability services like automated backup , automated High Availability with Always On AG, automated patching and performance optimized storage configuration.  

 

Today, we are enabling a new way of registering with SQL VM RP for customers running many SQL Server instances on Azure VMs. Bulk registering with SQL VM RP is using the new Azure power shell modules to automate registering with SQL VM RP for a list of subscriptions. 

 

Bulk Registration Script

Bulk registration script will iterate over all VM’s owned by the resource group, subscription or list of VMs provided as input and execute register with SQL VM RP command for all. If the VM is uprunning Windows Server 2008 R2 and above and had a SQL instance, then registration will be successful. All failures are queued and retried 3 times at the end of the first execution. Registration is always in Lightweight management mode with no impact to SQL Server instance or the VM resources. The lightweight agent will simply verify the edition and version of the instance, SQL server instance will not be restarted.  

 

Bulk registration is a great way to report on your Azure VM assets. At the end of execution, the script will create a detailed report  including Total VMs Found, VMs Already registered, Number of VMs registered successfully, Number of VMs failed to register due to error, Number of VMs skipped as VM or the guest agent on VM is not running and Number of VMs skipped as they are not running SQL Server On Windows.

 

Bulk registration can be executed from any machine with latest Azure PowerShell or CLI environments. The account running the script should have “Virtual Machine Contributor, Contributor or Owner” permissions for the virtual machine being registered in one of the RBAC access levels. 

 

Fully Customizable

Full Script is available on GitHub with full documentation. You can use the script as is or customize the script to suit your asset's specific requirements. For example, you can disable the retry of failures to shorten the execution time by or reduce the retry time by updating parameter values as shown below.

   #Retry options
    Set-Variable MAX_RETRIES -option ReadOnly -value 1
    $retryCount = 0
    $retryIfRequired = $false

 

If you will run the bulk registration on a very large asset, to parallelize the execution and shorten completion time and you can run the script individually for each resource group or with a given list of VMs. 

Register-SqlVMs -Subscription SubscriptionId1 -ResourceGroupList ResourceGroup1

 

You can use the script in report only mode, to assess the time to complete by removing the Registration call. For reporting only execution, please remove the calls below. Report only mode can show you total VM count, how many VMs are already registered, number of VMs will be skipped and target VM count for registration.

 

register-SqlVMForSubscription -Subscription $Subscription -Credential $credential `
                -ResourceGroupName $ResourceGroupName -Name $Name

 

 

No billing impact

Running Bulk registration script will not change anything on your current Azure Bill. It will read  the existing billing tags on the VMs as is.  If you created the VM from an Azure Marketplace SQL Server image with PAYG billing then it will continue as PAYG billing model. If you self-installed SQL Server on the VM, then it will be registered as AHB (Azure Hybrid Benefit) license model which tells that you are using existing on-premises SQL Sever licenses and Software Assurance to license that SQL Server instance. There is no license verification involved and License compliance is out of scope for SQL VM RP registration as it is owned by customer. Free edition of SQL Server will be registered in PAYG mode and will not generate any SQL License bill.

 

Install the latest version of Az Module today and with a single command bulk register all VM’s running SQL with SQL VM RP to leverage the free manageability services and optimize your return of investment on Azure. 

 

 

Version history
Last update:
‎Jun 19 2020 10:01 AM
Updated by: