Tuesday, 23 June 2020

Register VM running SQL as SQL VM in Microsoft Azure **



Microsoft has create a new section in Azure called SQL Virtual Machine, This section is mainly to make azure admin task only view SQL  VM .

Below are some keys benefit of that : 

  • Feature benefits: Registering your SQL Server VM with the resource provider unlocks automated patchingautomated backup, as well as monitoring and manageability capabilities. It also unlocks licensing and edition flexibility. Previously, these features were only available to SQL Server VM images deployed from Azure Marketplace.
  • Compliance: Registering with the SQL VM resource provider offers a simplified method of fulfilling the requirement to notify Microsoft that the Azure Hybrid Benefit has been enabled as is specified in the product terms. This process negates needing to manage licensing registration forms for each resource.
  • Free management: Registering with the SQL VM resource provider in all three manageability modes is completely free. There is no additional cost associated with the resource provider, or with changing management modes.
  • Simplified license management: Registering with the SQL VM resource provider simplifies SQL Server license management, and allows you to quickly identify SQL Server VMs with the Azure Hybrid Benefit enabled using the Azure portal, the Az CLI, or PowerShell:
I just took from Microsoft docs as they has a very good explanation of that. Click here to the actual page.


Lets start register all the VM running SQL and enjoy the benefit. 

Step 1.Download the sql VM module and place it accordingly in your desired location.  Please refer to this link to download – Click here and here to download the module. Make sure you are running Az module for this to work. 


Step 2 Open Powershell ISE ; for better editing , to start doing the step.

Step 3. Navigate to desired loction and import the module
cd 'C:\Users\AbdulMunirBinMohamad\sql’
Import-Module .\RegisterSqlVMs.psm1

Step 4. Login to azure and choose your desired subcription (if any)
Login-AzAccount
Select-AzSubscription -Subscription "xxxxxxxxxxxxx" #this is dev sub ID

Step 5 . Modify the resource group name and vm name accordingly and run the command.
New-AzSqlVM -Name sqlsvr01 -ResourceGroupName SQLserverRG -LicenseType AHUB -SqlManagementType Full -Location southeastasia

*Please note that this process will restart the SQL instance, do plan the time accordingly

Step 5 . Check the status of the SQL VM from the following command .
Get-AzSqlVM -ResourceGroupName SQLserverRG -Name sqlsvr01


The whole powershell as follow.
cd 'C:\Users\AbdulMunirBinMohamad\SQL'
Import-Module .\RegisterSqlVMs.psm1
Login-AzAccount
Select-AzSubscription -Subscription "xxxxxxxxxxx"
New-AzSqlVM -Name sqlsvr01 -ResourceGroupName SQLserver -LicenseType AHUB -SqlManagementType Full -Location southeastasia
Get-AzSqlVM -ResourceGroupName SQLserverRG -Name sqlsvr01 


After all of this done, you can start search SQL Virtual Machine, then all your SQL virtual machine registered with SQL provider will appear. All SQL management task can be carry from there, here is sample. 


Enjoy.. 

Kubecost on AKS Part 02