Azure via APIs, Powershell and YAML; The Rhodes Way

2 min read

The Azure Resource Manager is limited in its capability to report results and errors.If you’re a long time user of ARM you’ll have found out its limitations in respects to this and found it frustrating when automating.

As a long time friend of mine Laurie Rhodes said to me recently:

“Although, I don’t have a problem doing everything in ARM (my templates from 2016 still work perfectly) I just really hate the notion of needing third party products for provisioning if I want to use something else. Nothing sums up the failure of IT to me more than this image! Doing everything with APIs directly is so much better than mucking around with ARM templates and third party products.”

As a result of his views Laurie has devised a solution to his problem to enact direct calls against the Azure APIs using Powershell and YAML. He has posted two key blogs about how to accomplish this and created a github repo

In post one Laurie discussed programmatically retrieving the latest Azure API versions for object types and showed the code behind ‘Get-AzureAPIVersions’. 

Being able to programmatically determine the latest API version for an object will let me use generic commands to create, modify and delete Azure objects using just their Id.

Lauries Rhodes

Obviously not be satisfied enough stating that this COULD be the case Laurie followed up creating the blog post to prove it here:

In summary of his method. You will need:

  • YAML Powershell module
  • Lauries AZRest PowerShell module

Lauries own AZRest power shell module is required to know the right version of API used when querying objects based on their ID.  The Object ID is written in the YAML templates. Having the latest object version is important for success and keeps pace with Azures innovations.

When ready the process to follow when creating Azure Resources is a four step method as below:

And that is it! That is the amount of commands you need to execute to make a VM from Lauries example in his post.

Of course a lot of the effort goes into defining the YAML 🙂 In order to help with this Laurie recommends you head off to the API Definitions as these are the properties of the resources you define in the YAML.

Nice job Laurie. I think I’ll be giving this a go next.