Automating the enabling of BYOS licensing for all SUSE VMs in Azure - Code Sample

@20aman    Dec 03, 2021

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

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

We also looked at the advantages of the BYOS over the PAYG model. You can review the previous post here: Switching SUSE 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-SUSEBYOSLicense

Script Workings

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

$vm.LicenseType = "SLES_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