Microsoft Canada ITPro - #canitpro
Sharing of thoughts and information is what blogging is all about. This way we can learn from each other. Post A Comment!These postings are provided "AS IS" with no warranties, and confers no rights. You assume all risk for your use.
Anthony Bartolo Twitter | LinkedIn
Pierre Roman Twitter | LinkedIn
Last week while I was traveling a reader (that’s you Jamie) reminded me that I had forgotten to write the promised part 2 of the “Getting Ready to use Azure Automation”. I don’t want to disappoint, so I jumped right on it.
Before diving into automation. I do recommend the following MVA modules as primer.
Now, let’s do this.
Before we start with the runbooks we need to create an automation account and populate it with objects that are needed by the runbooks. Just follows the steps listed in Step-by-Step: Get Ready to use Microsoft Azure Automation. But for today we added and additional asset.
I created the following settings in my Automation account:
The Runbook scripts can reference objects stored in the automation account.
In our case, we stored a management certificate, a set of credentials, and a connection. The connection will use the certificate .PFX file, which contains the private key, to authenticate itself to the subscription when performing VM actions.
In order to run the test we need to create a new storage account in which we will upload the Windows PowerShell module that will be installed in each VM.
In the Azure Management Portal, click STORAGE, click NEW, and then click QUICK CREATE.
I used the following name, auto7152311. In LOCATION/AFFINITY GROUP I selected US East since it’s the closest to me. and Click CREATE STORAGE ACCOUNT.
In the auto7152311 storage account click CONTAINERS and click ADD in the Action bar at the bottom.
In the New Containers dialogue box enter modules as the name and Public Container as the access. this is needed for one of the runbooks later.
I used Azure Storage Explorer (http://azurestorageexplorer.codeplex.com/) to upload PSWindowsUpdate.zip (You can find the file here (http://aka.ms/runbooks)
In this task, you will deploy a new VM to test your automation solution. The runbooks provided review all VMs in a subscription and provide information on missing updates. This VM will be created in the background while you complete the rest of this lab.
1- In Azure Management Portal, click NEW, click COMPUTE, click VIRTUAL MACHINE, and then click QUICK CREATE.
Provide the required information and then click CREATE A VIRTUAL MACHINE. In my Case I called the machine autoVM2311.
now we will import pre-created runbooks. Runbooks are Windows PowerShell automation scripts containing workflows, which are written to run in Azure Automation. yo can find more info on authoring your own runbooks here
There is little difference between Windows PowerShell automation scripts that run in Azure Automation, and those that run locally, making the scripts very portable.
In the Azure management portal, we need to navigate to AUTOMATION and CANITPRO-Auto , and then click RUNBOOKS.
I am making some sample runbooks available for you here (http://aka.ms/runbooks) save them locally to be used in this step-by-step tutorial.
Click BROWSE FOR FILE, and then browse to where you saved the samples and select Connect-Azure.ps1.
Click Open, and then click the Done icon.
Repeat this process to import the following runbooks,
you will end up with the following:
In RUNBOOKS, click Connect-Azure, and then click AUTHOR.
Click PUBLISH, and then click Yes.
Repeat this process to publish each remaining runbook EXCEPT Update-AzureVM. This runbook must be modified.
Click Update-AzureVM. and in the DRAFT view, make the following modifications. You can type directly in the code view.
Credentials to access each VM.
Indicate the name of your storage account
Replace “psmodules” with “modules”
Indicate the storage container.
Click SAVE, click PUBLISH, and then click YES.
Note: Before we test the runbook on the VM we created earlier. We need to RDP into it and change the execution policy in PowerShell and enable Remote PowerShell by typing the following commands in a powershell console on that VM.
Now that this is done, we can go back to the Azure management portal and navigate to AUTOMATION, CANITPRO-Auto, RUNBOOKS, click Update-AzureVM to get in the runbook. and click DASHBOARD.
On the bottom bar, click START, and then click YES.
When the runbook starts, click JOBS and select the job that just started.
Review the output pane for a list of needed updates in the VMs.
That’s it folks…. you just automated your first tasks in Azure…
I encourage you to try your hand at writing your own runbooks and harness that power.
Until next time I’m off for a few days on a much needed vacation.
Pierre Roman | Technology EvangelistTwitter | Facebook | LinkedIn