Home Algemeen Automation Account module deployment with Bicep

Automation Account module deployment with Bicep

door Manfred de Laat

It’s a little bit strange to say, but I have created a script that automates the build of an automation file (Bicep file) that helps you deploy modules into an Automation Account so you can automate more repetitive tasks from there… yeeaaah! But why would you want to do that? Let me explain.

I like to use my own runbooks inside Automation Accounts to do all kind of tasks in my Azure environments and in the most cases I am using multiple Az PowerShell modules to do the job. Since we are building all kind of Microsoft related automation stuff (On behalf of my and Leon’s company CloudAssist) we want to deploy Automation Accounts with bicep. And when we deploy Automation Accounts we always want to use the latest module versions.

The challenge

The nice thing about the common Az modules (Az.Network, Az.Compute etc) is that there is a lot of development and updates for that modules. The downside is that you have to update your automation solutions so they contain the latest modules every time you are releasing a new build. Another downside is that the most Az modules are depending on a particular minimum version of Az.Accounts and a handful of Az modules depending on other Az modules like Az.Profile and Az.Resources. If a PowerShell module has a dependency than you need to install that dependency module first.  It can be very challenging to keep up with all of the changes so I decided to create a PowerShell script to do the plumbing.

The solution

I love to be a lazy admin since forever and let all kind of automation techniques do the work for me for ages. Also in this case I found a solution that saves some time so I can drink at least one Corona (or maybe another beer) extra with my friends every time I am creating a new build. I’ve created a PowerShell script that checks your input modules in the PowerShell Gallery, uses the dependency information and deals whit possible dependencies in the outputted bicep file. This script does not provide you with a total solution, but helps you to build your own bicep files. Please use the script and modify it so it works best for you. Also please take a look at the limitations.

The action

The inputfile
The compiled Bicep file, all dependencies are in place.

The limitations

I am not dealing with things like checking minimum, maximum and required dependencies. I am also not checking more then one level of dependencies, but if you make sure that your input list is as complete as possible you will be fine most of the time. You can change the script so it will fits your needs. Importing modules in a automation account fails regularly, so make sure you deal with that in your automation solution.

Download script

The script is placed in my Github repo you are more then welcome to download it from there!

Related Posts

Laat een Opmerking achter

Deze website maakt gebruik van cookies. Accepteer Lees Meer

Geverifieerd door MonsterInsights