Changing the License Type for an existing Virtual Machine Scale Set to use the Azure Hybrid Use Benefit

If you are an enterprise customer that has existing Windows Server licenses that you want to use in Azure, you can take advantage of the Azure Hybrid Use Benefit to bring those licenses to the cloud. We have those steps documented for a number of scenarios here: https://docs.microsoft.com/en-us/azure/virtual-machines/windows/hybrid-use-benefit-licensing. However, what if you want to convert to AHUB once you’ve already deployed your VM Scale Sets? The methods described in the above article do not currently include how to do this for an existing VMSS deployment.

Here is the PowerShell to make the change:

$rg = "TestVMSS-RG" #change for your resource group

$VMScaleSetName = "PeteVMSS02" #change for your virtual machine scale set name

$vmss = Get-AzureRMVMss -ResourceGroupName $rg -VMScaleSetName $VMScaleSetName

$vmss.VirtualMachineProfile.LicenseType = "Windows_Server"

Update-AzureRmVmss -ResourceGroupName $rg -VMScaleSetName $VMScaleSetName -VirtualMachineScaleSet $vmss

Update-AzureRmVmssInstance -ResourceGroupName $rg -VMScaleSetName $VMScaleSetName -InstanceId "*"