DEV Community

Alexey Melezhik
Alexey Melezhik

Posted on

Azure Automation with Perl6 and Sparrow6

Sparrow6 is a automation tool written on Perl6 and comes with a lot of plugins allowing users automate their daily tasks.

In this short post I'm going to show you how to automate interaction with Azure KeyVault. This case is typical as it often happens when one need to read secrets from keyvault and use them somehow.

Installing Sparrow6

zef install

Setup Sparrow6 repostory

export SP6_REPO=

Simple scenario

Let's create a simple scenario that loads login and password from keyvault and uses them to ssh to linux VM and then run uptime command for this machine.

We're going to use Tomtit task runner
to execute Sparrow6 scenario, as Tomtit is a good fit for command line applications:

zef install

Now let's create scenario:



# Set Azure Account 
task-run "set az account", "azure-account-set" %(
  subscription  => "foo-bar-baz"

# Load keyvault secrets from Azure KeyVault
my %state = task-run "load login and password", "azure-kv-show", %(
  kv      => "Stash" # key vault name
  secret  => ( "password", "login" ) # secret names

my $host = "";

# Run uptime for linux host, using loaded credentials
bash "ssh-pass -p {%state<password>} ssh -l {%state<login>} $host uptime"
Enter fullscreen mode Exit fullscreen mode

Run scenario

Now after authenticating through service principal which is used to make requests to Azure, we can run scenario:

az login --service-principal -u $app_id --tenant $tenant_id -p $password

tom ssh-uptime

Thank you for reading. If you find the post useful, let me know and I'll probably create new ones on the same topic.

Top comments (2)

lizmat profile image
Elizabeth Mattijsen

Where does the bash come from? I don't recall that being a Perl 6 standard function?

melezhik profile image
Alexey Melezhik

Hi! bash is part of Sparrow6 DSL -