Automating the enabling of BYOS licensing for all Red Hat Enterprise Linux (RHEL) VMs in Azure - Code Sample

@20aman    Nov 27, 2021

In the previous post we looked at the difference between two deployment models to choose from when deploying Red Hat Enterprise Linux VMs (RHEL):

  • PAYG - Pay as you go
  • BYOS - Bring your own subscription

We also looked at the advantages of BYOS over the PAYG model. You can review the previous post here: Switching RHEL VMs from PAYG to BYOS model.

In this post, we look at automating the process via a complete code sample.

Script Location

The complete script can be found on the GitHub here: Enable-RHELBYOSLicense

Script Workings

The script works by setting the license type property of the VM to "RHEL_BYOS".

$vm.LicenseType = "RHEL_BYOS"

The script then leverages the "Update-AzVM" cmdlet to update the VM with the license property.

Update-AzVM -VM $vm -ResourceGroupName $currentRGName

Make sure you update the input subscription name and also the Resource Group name. In the script, it uses Wildcard to find all resource groups that start with the string mentioned before "*". You can use a similar wildcard match for the string or you can provide a specific Resource Group name.

Let me know if this helped you in any way in the comments below or at GitHub.





Comments powered by Disqus