Earlier this week, Microsoft Azure Automation was made available on the Microsoft Azure cloud platform as a public preview. This new feature allows you to automate the creation, monitoring, deployment and management of cloud resources in your Microsoft Azure subscription using a highly-available workflow execution engine. Azure Automation provides an orchestration feature set for public cloud resources that is similar to what the Service Management Automation (SMA) engine provides for on-premises private cloud resources via the Windows Azure Pack and System Center 2012 R2 Orchestrator.
Azure Automation is super-cool, because it allows us to perform automated cloud provisioning and management without needing to manually build and manage a separate set of automation servers. And … scalability and high availability of the Azure Automation engine is provided natively via the Microsoft Azure cloud platform without any extra configuration steps, which helps to make sure that your scheduled runbooks will always execute when needed.
In this article, I’ll step through the process of getting started with Azure Automation. Along the way, we’ll build a runbook and PowerShell workflow for performing basic automation of Microsoft Azure virtual machines.
To leverage Microsoft Azure Automation, you’ll need an active Azure subscription with the Microsoft Azure Automation preview feature activated.
Azure Automation authenticates to Microsoft Azure subscriptions using certificate-based authentication. You can create and export a new management certificate using the Internet Information Services (IIS) Manager tool from any Windows Server installed with the IIS Web Server role and management tools.
Use the steps below to create and export a new management certificate from a server running Windows Server 2012 or 2012 R2. After creating a new certificate, you will export this certificate as a .CER file for uploading to your Microsoft Azure subscription and also as a .PFX file for uploading to your Azure Automation account.
Now that you have a new management certificate created and exported, you’ll need to upload the exported .CER file to your Microsoft Azure subscription.
For your Azure Automation account to be able to authenticate to your Microsoft Azure subscription, you’ll also need to upload the certificate .PFX file. You’ll upload this certificate as an Asset in your Azure Automation account so that it can be consistently leveraged across multiple runbooks.
You can also define the connection information for your Microsoft Azure subscription as an Asset in your Azure Automation account. Doing so allows you to easily relate your Microsoft Azure subscription name, subscription ID and management certificate together as a centralized definition for use in all of your runbooks.
There's a few lines of code that are used to connect a runbook to your Microsoft Azure subscription using the management certificate asset and connection asset that were previously defined. To promote easy maintenance of runbooks, we recommend centralizing this code into one Connect-Azure runbook that other runbooks can reference.
Luckily, the Azure Automation team has made this approach super-easy by providing us with a standard runbook template on the Azure Automation Script Center.
We’re ready to create a runbook for automating the provisioning and management of cloud resources in your Microsoft Azure subscription. In this article, the runbook we’ll create will be used to automate the safe shutdown of on-demand lab virtual machines at the end of each day. This runbook will stop and deallocate each specified virtual machine so that compute charges for these lab VMs do not continue to accrue when they are not being used.
After saving the draft runbook, you can test the new runbook to confirm that it executes successfully.
When you’ve tested the runbook and confirmed that it executes successfully, you can publish the new runbook for running on a scheduled basis.
We want this new runbook to execute at the end of every day, to make sure that our lab VM’s are automatically stopped and deallocated when not being used. To execute a runbook on a scheduled basis, we can link the runbook to a recurring schedule.
In this article, we’ve created a simple Azure Automation runbook to stop and deallocate lab VMs on the Microsoft Azure cloud platform. This runbook provides a great starting point, but it’s just one example of the power of this new preview feature. Azure Automation can leverage any of the Microsoft Azure PowerShell cmdlets for automating more sophisticated cloud tasks, and we can also extend Azure Automation by importing additional PowerShell modules.
When you’re ready to learn more about Azure Automation, be sure to check out the additional resources available on our Microsoft Azure documentation portal:
Are there particular cloud scenarios in which you have interest? Feel free to leave your comments and feedback below, and we’ll try to write-up as many additional scenarios as possible in the coming weeks.
See you in the Clouds!
Be sure to check out these additional resources:
Keith Mayer is a Senior Technical Evangelist at Microsoft focused on Cloud and Enterprise platforms. Keith has over 20 years of experience as a technical leader of complex IT projects, in diverse roles, such as Network Engineer, IT Manager, Technical Instructor and Consultant. He has consulted and trained thousands of IT Pros worldwide on design of enterprise technology solutions.
Keith is currently certified on several Microsoft technologies, including Private Cloud, System Center, Hyper-V, Windows, Windows Server, SharePoint and Exchange. He also holds other industry certifications from VMware, IBM, Cisco, Citrix, HP, CheckPoint, CompTIA and Interwoven.
You can contact Keith online at http://aka.ms/AskKeith.