In my @work I do a lot of scripting that allow me to automate creation and managing various Azure resources.
Sparrow6 - Perl6 automation framework has a lot of ready plugins to get job done.
It supports both Windows and Linux operation systems.
Install Sparrow6
We will use Sparrow6 and Tomtit as automation frameworks
zef install Sparrow6 Tomtit
Setup Repository
Sparrow6 public repository has all the plugins we need:
export SP6_REPO=http://repo.westus.cloudapp.azure.com
Login to Azure
Let's create first scenario that login to Azure using app registration credentials:
tom --edit azure-login
:
task-run "login to azure", "azure-login", %(
tenant => config()<azure><tenant>, # Azure Tenant ID
app_reg => config()<azure><app-reg>, # Application registration URL
password => config()<azure><password>, # Password ( AKA client secret )
subs => config()<azure><subscription> # Subscription ( name or id )
)
Configuration file
We're going to keep all the configuration data inside Tomtit environment:
tom --env-set dev
%(
azure => %(
tenant => "ad777dcc-bf12-4234-b41c-33b355cb1a52",
subscription => "Smart Species",
app-reg => "https://birds.azure.zoo.org",
password => "Black Crow"
)
)
tom --env-set dev
Run scenario
Let's run our very first scenario:
tom azure-login
Now when we've successfully logged to Azure we could manage resources. Following are just some examples.
Azure Keyvault
azure-kv-secrets-check
plugin allows to retrieve a list of secrest from Azure keyvault and optionally check if they exists there.
tom --edit check-secrets
task-run "check secrets", "azure-kv-secrets-check", %(
name => "hidden-stash",
exists => (
"bank-account",
"home-PC",
"credit-card" # I don't use that staff
)
)
Digging deeper
Sparrow6 provides you with some plugins to automate interaction with Azure.
To browse existing ones go to Sparrow plugins GitHub project or use command line interface:
s6 --index-update
s6 --search azure
s6 --plg-install azure-kv-secrets-check
s6 --plg-man azure-kv-secrets-check
I've been constantly adding new plugins and try to support both Windows and Linux systems. Many of plugins require just a azure command line client.
Thank you for reading.
Comments and feedback are welcome.