Azure Automation: update them modules

Azure Automation: update them modules

I have been working a lot with Azure Automation lately. It’s a great product, helping organize the use of Powershell making an awesome language even better.

With AA as any other of the Azure services there are always some challenges, one is modules and how some keep ever changing…I’m looking at you AzureRM. This is why I wanted to get some automation into this process. And as it is in the product name this is only fitting.

Browsing the AA teams github I found the following Runbook that looked promising. Though in testing it has some issues with modules on gallery that did not use the same title as module name, like you know AzureAD. Therefore I did some fast triaging to get it into shape. As with everything, check to see if somebody else already have figured it out before creating the wheel anew. Browsing the web this guy had it all figured out, so I borrowed the code.

Here is the updated version that updates the modules in AA, just add it as a Runbook and schedule it to run as often as needed:

Now that should have been it, though as there currently is no connection between AA and the Hybrid Workers, modules deployed there are forever in the twilight zone. Therefore I needed to address this also. Note, you will still have to manually install the modules you want the first time, though the below Runbook should help keep them up to date. Though you must remember to install these modules in the first place using “Install-Module”, else the logic will not keep them updated for you.

A couple of things to be aware of, you will need to create a couple of assets in AA.


AAResourceGroupName as a string variable with the name of the AA resourcegroup,
AAAccountName as a string variable with the name of the AA account,
AAHybridWorkerName as a string variable with the name of the hybrid worker group,
AAWorkerAdminCredential as a credential object with a user that is local admin on all the workers.

Also the script is set up to use the default RunAs service principal, so the AA account will need to have this set up. You will also need to target the Runbook to run on the hybrid worker group.

Happy tinkering!