EDIT: This functionality is now directly in the portal. Just select the VM, click configuration and you should now see the ability to switch license type.
Microsoft has recently announced their hybrid use benefit for Windows virtual machines. They claim a 40% lower price on Windows VMs in Azure which is certainly a good thing.
If you license your on premises hosts with Windows Datacentre and also run some Azure Windows VMs then you can use the license for both - at the same time!
"Each two-processor licence or each set of 16-core licences are entitled to two instances of up to 8 cores, or one instance of up to 16 cores. The Azure Hybrid Use Benefit for Standard Edition licences can only be used once either on-premises or in Azure. Datacenter edition benefits allow for simultaneous usage both on-premises and in Azure."
The only issue with this offer is that you need to enable the hybrid use at deploy time on your VMs. This isn't a problem for ephemeral VMs, but if you have permanent VMs that you want to save some money on, then you need to re-provision them.
It is possible to delete your VMs and then recreate them using the original VHD, with the hybrid use benefit enabled. I've written a script which will do just this and published it on GitHub here.
As always, DO NOT use this in production and make sure you have backups of your machines before you use the script!
Be aware that this will only work on some VMs, I've not yet worked out the prerequisites. The script *should* detect if it hasn't worked and put your VM back with it's original license if the ARM platform throws an error. To put this in perspective, I've run the script on 8 VMs, 1 of which didn't work.
Update: Should now work with managed disk VMs
Good day. Great script thanks.
ReplyDeleteAs far as I can see it works fine on a server with a storage account but unable to run on B-Series VM's and Managed Disk VM's.
Do you maybe have an updated version on where VM's with managed disks can be converted?
Regards
Hi, I've updated the script to work with managed disk VMs.
DeleteI've tested on a B Series VM and it works, if there is still an issue, can you explain it and paste the error please.
Thanks for your feedback.
This is the only version I have at present, I've not tested on B series or managed disk VMs.
ReplyDeleteI haven't looked at how to remove / re-add a VM with a managed disk, but I assume the issue is when re-attaching the disks to the VM since I guess there will be no URI for the disk.
If I get some time, I'll take another look.
This comment has been removed by a blog administrator.
ReplyDeleteHi
ReplyDeleteIt fails for me with this error, the vm is using managed disks.
I'm not sure why its complaining about the below storage account ('xxxxxazurexxx' )?
Any idea why, please let me know?
Standard DS2 v2 (2 vcpus, 7 GB memory)
Recreate the VM...
New-AzureRmVM : Long running operation failed with status 'Failed'.
ErrorCode: StorageAccountTypeNotSupported
ErrorMessage: Storage account 'xxxxxazurexxx' is of Standard_ZRS type. Boot Diagnostics supports
Standard_GRS,Standard_LRS,Standard_RAGRS storage account types.
StartTime: 06/11/2017 12:26:31
EndTime: 06/11/2017 12:26:31
OperationID: ff83ce40-d005-4e61-a3c2-6ee6687f56e7
Sounds like that storage account is in use for VM diagnostics maybe? I'll make a VM with diagnostics enabled and see if I can reproduce
DeleteWorks fine with a configured boot diagnostics account on a VM for me.
DeleteLooks like your diagnostics storage account is ZRS which is not supported and that's why the VM can't be recreated.
I'm not sure how you created that VM in the first place? I'm unable to set my boot diagnostics account in the portal to a ZRS storage account. Because of this I can't really fix this issue.
Hey Dave, how would you go about using the XML file to restore a VM if you have issues with the script?
ReplyDeleteI would actually ignore the xml and create a new VM of the same size and attach the VHD using PowerShell:
Deletehttps://blogs.infosupport.com/creating-a-vm-in-azure-based-on-an-uploaded-vhd/
Or the Quickstart Template
https://www.ntweekly.com/2016/08/18/how-to-create-an-azure-vm-from-existing-image-vhd-in-the-new-azure-portal/
Just as a side note. The option to convert on the fly is now in the portal. Select the VM and go into config.
ReplyDeleteGreat news!
Delete