Provision Azure Environment Resources
This is where we can see proof of evolution.
As you saw in the bulleted list of chronological blog posts (above), my first venture into Automating the Public Cloud leveraged Orchestrator + The Integration Pack for Windows Azure. My second releaseleveraged PowerShell and PowerShell Workflow + Windows Azure Cmdlets.
Let’s get down to the goods. And actually, for the first time in a long time, my published example came out a couple days before the blog post / teaser!
Script Center Contribution and Download
The download is the example: New-AzureEnvironmentResources.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, Azure Storage Container, Azure VM Image, and Azure VM. It also requires the Upload of a VHD to a specified storage container mid-process.
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).
A bit more about the Requirements…
- Azure Connection Name
REQUIRED. Name of the Azure connection setting that was created in the Automation service.
This connection setting contains the subscription id and the name of the certificate setting that
holds the management certificate. It will be passed to the required and nested Connect-Azure runbook.
- 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
An existing connection to an Azure subscription
The Upload of a VHD to a specified storage container mid-process. At this point in the process, the runbook will intentionally suspend and notify the user; after the upload, the user simply resumes the runbook and the rest of the creation process continues.
Six (6) 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’
$GenericStorageContainerName = Get-AutomationVariable -Name ‘GenericStorageContainer’
$SourceDiskFileExt = Get-AutomationVariable -Name ‘SourceDiskFileExt’
$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.
Upload of a VHD
Waaaaait a minute! That seems like a pretty big step, how am I going to accomplish that?
I am so glad you asked.
To make this easier (for all of us), I created a separate PowerShell Workflow Script to take care of this step. In fact, it is the same one I used during the creation and testing of New-AzureEnvironmentResources.ps1.
Here it is (the contents of a file I called Upload-LocalVHDtoAzure.ps1):
Note This is just one method of uploading a VHD to Azure for a specified Storage Account. I have parameterized the entire script so it could be run from the command line as a PS1 file. Obviously you can do with this as you please.
Testing and Proof of Execution
I figured you might want to see the results of my testing during my development of the Provision Azure Environment Resources example…so here are some screen captures from the Azure Automation interface:
Azure All Items View
You know, to prove that I created something with these scripts…