If you’re an enterprise customer that has existing Windows Server licenses that you want to use in Azure, you can take advantage of 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 don’t include how to do this for an existing VMSS deployment.
Here is the PowerShell to make the change:
$rg = "<ResourceGroup>" #change for your resource group
$VMScaleSetName = "<VMScaleSetName>" #change for your virtual machine scale set name
$vmss = Get-AzureRMVMss -ResourceGroupName $rg -VMScaleSetName $VMScaleSetName
$mode = $vmss.UpgradePolicy.Mode
if ($mode -eq "Automatic")
$vmss.VirtualMachineProfile.LicenseType = "Windows_Server"
Update-AzureRmVmss -ResourceGroupName $rg -VMScaleSetName $VMScaleSetName -VirtualMachineScaleSet $vmss
$capacity = $vmss.Sku.Capacity
for ($count = 1;$count -le $capacity;$count++)
$vm = Get-AzureRMVMssVM -ResourceGroupName $rg -VMScaleSetName $VMScaleSetName -InstanceId $count
$vm.LicenseType = "Windows_Server"
Update-AzureRmVmssInstance -ResourceGroupName $rg -VMScaleSetName $VMScaleSetName -InstanceId $count