Automation–Microsoft Azure Automation–Provision Azure Environment Resources from Gallery

Hello Readers!

As you may recall, I published this post (Automation–Microsoft Azure Automation–The Evolution of Cloud Automation) last month, as my first experience with Microsoft Azure Automation. It illustrated the evolution – my evolution – through and to where we are with Cloud Automation.

Here I am again, with a new script – well, in truth, a new version of that script – which makes things a little easier to provision a VM with one click and the completion of a form (taking in Runbook parameters).

So, no long post, no big explanation…just a link to the script, and the hope that you will find it useful.


Script Center Contribution and Download

The download is the example: New-AzureEnvironmentResourcesFromGallery.ps1

Here is a brief description:

This runbook creates a number of Azure Environment Resources (in sequence): Azure Affinity Group, Azure Cloud Service, Azure Storage Account, and Azure VM all from an existing VM Image (specified as a Variable in the Assets).

A detained Description, full set of Requirements, and the actual Runbook Contents are available within the Script Center Contribution (not to mention, the actual download).

Download the Provision Azure Environment Resources from Gallery Example Runbook from Script Center here:

BC-DLButtonDark


A bit more about the Requirements…

(same as previous script)

Runbook Parameters

  • Project Name

  • REQUIRED. Name of the Project for the deployment of Azure Environment Resources. This name is leveraged
        throughout the runbook to derive the names of the Azure Environment Resources created.

  • VM Name

    REQUIRED. Name of the Virtual Machine to be created as part of the Project.

  • VM Instance Size

    REQUIRED. Specifies the size of the instance. Supported values are as below with their (cores, memory)
        "ExtraSmall" (shared core, 768 MB),
        "Small"      (1 core, 1.75 GB),
        "Medium" (2 cores, 3.5 GB),
        "Large"      (4 cores, 7 GB),
        "ExtraLarge" (8 cores, 14GB),
        "A5"         (2 cores, 14GB)
        "A6"         (4 cores, 28GB)
        "A7"         (8 cores, 56 GB)

  • Storage Account Name

    OPTIONAL. This parameter should only be set if the runbook is being re-executed after an existing
    and unique Storage Account Name has already been created, or if a new and unique Storage Account Name
    is desired. If left blank, a new and unique Storage Account Name will be created for the Project. The
    format of the derived Storage Account Names is:
        $ProjectName (lowercase) + [Random lowercase letters and numbers] up to a total Length of 23


Other Requirements

  • This runbook sample leverages organization id credential based authentication (Azure AD; instead of the Connect-Azure Runbook). Before using this runbook, you must create an Azure Active Directory user and allow that user to manage the Azure subscription you want to work against. You must also place this user's username / password in an Azure Automation credential asset.

    You can find more information on configuring Azure so that Azure Automation can manage your Azure subscription(s) here: https://aka.ms/Sspv1l

    It does leverage an Automation Asset for the required Azure AD Credential. This example uses the following call to get this credential from the Asset store:

    $Cred = Get-AutomationPSCredential -Name 'Azure AD Automation Account'
    $AzureSubscriptionName = Get-AutomationVariable -Name 'Primary Azure Subscription'

  • Five more (5) Automation Assets (to be configured in the Assets tab). These are suggested, but not necessarily required. Replacing the "Get-AutomationVariable" calls within this runbook with static or parameter variables is an alternative method. For this example though, the following dependencies exist:
        VARIABLES SET WITH AUTOMATION ASSETS:
            $AGLocation = Get-AutomationVariable -Name 'AGLocation'
            $VMImage = Get-AutomationVariable -Name 'VMImage'
                Example Image: a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-R2-201404.01-en.us-127GB.vhd
            $VMImageOS = Get-AutomationVariable -Name 'VMImageOS'
            $AdminUsername = Get-AutomationVariable -Name 'AdminUsername'
            $Password = Get-AutomationVariable -Name 'Password'

Note The entire runbook is heavily checkpointed and can be run multiple times without resource recreation.


Thanks for checking out my blog post! For more information, tips/tricks, and example solutions for Automation within System Center, Windows Azure Pack, Microsoft Azure, etc., be sure to check out the other blog posts from Building Clouds in the Automation Track!

enJOY!