Creating the Start Script
If you have ever worked with the Azure PowerShell cmdlets, you will know that all of them require parameters and many of them create output variables as well and that is how the flow of is created within the Graphical Editor. Below you will find the Start script that I created for the customer. Let me walk you through what this image is and how it actually does Start a specific set of VMs.
Figure 1: Graphical View of Start Script
- This script is run using an Azure Automation RunAs Account which is considered a Service Principal User within the Azure Active Directory tenant associated with your Azure Subscription.
- The Service Principal Account is created as a Connection asset within the Azure Automation Account.
- This Service Principal account is passed as a parameter to the “Login to Azure” command from the “Get RunAs Account” command
- Each box corresponds to a PowerShell cmdlet, however they are given more user friendly display names. i.e. “Login to Azure” = Add-AzureRmAccount
- All input parameters are configured within the Graphical Editor specific to each cmdlet. In this case, the majority of the parameters are specified as Variables assets that are stored within the Azure Automation Account. Please see Figure 2:
- Each arrow shows that a single or an array of output objects are passed on to the next command.
- Each arrow can be customized to filter the output.
- The arrows that are shown as dotted line are ones that have been modified to filter the objects based on a specific set of logical operations before passing them to the next command. Please see Figure 3:
- The last set of commands are used to provide notifications back to the Console and therefore, back to the Runbook Auditing engine whether the Start/Stop process succeeded or failed. Using these commands allows you to add additional auditing beyond what Azure provides out of the box.
Figure 2: Configuring Parameters for Cmdlet
Figure 3: Filter the Flow of Objects between Commands
I hope that this shows that it is perfectly reasonable to create simple to mediocre complexity level scripts using a completely graphical and configurable method rather than a pure coding method. In addition to the information that I have provided above, I have published both of the scripts to the Technet Script Gallery so that they can be imported into the Azure Automation Runbook gallery and consumed by other customers. The links to these script repositories are listed below in the Additional Resources section.