Q: How can I get started with Azure Automation?
A: Getting started with Azure Automation requires a few key things. Even though Azure Automation is running within Azure, you still need to use a management certificate to enable communication from Azure Automation runbooks to an Azure subscription. If you don't have a standard management certificate, you can follow the instructions in "Q: How do I create a certificate to enable System Center App Controller to manage Windows Azure?" to create one. Once you have the private key for the certificate in a PFX file and the public key is uploaded to Azure as a management certificate, follow these steps:
- Create a new Azure Automation account. In the Azure management portal, go to the Automation workspace and select the Create action. Select a name for the new automation account and the region in which it should be hosted.
- Select the Automation account, select the Assets tab, and select the Add Setting action. Select Add Credential, Certificate; specify a name for the certificate. (Make a note of the name you specify, because you'll need it in the next step.) On the next screen, select your PFX file that contains the private key; enter the password for the PFX file and click the tick icon.
- Add the Azure subscription under same account. On the account's Assets tab, click the Add Setting action; select Add Connection. Under Connection Type, select Azure and specify a name. On the next screen, specify the name of the certificate uploaded in step 2, provide the Azure subscription ID, and click the tick icon.
- Download the necessary script to easily connect to Azure from your runbooks. Download Connect-Azure.ps1 from the Microsoft TechNet article "Connect to an Azure Subscription." Use the Runbook, Import option to upload the script. Select the runbook; on the Author tab, select Published and click Yes.
Create your own runbooks. On the Automation account's Runbooks tab, select New, Runbook, Quick Create. Give the runbook a name and description. (You can also change the automation account and Azure subscription.) Select the Runbook; on the Author tab, edit the Draft version of the runbook. You'll have a default workflow; the first actions should be to connect to the Azure subscription that you want to perform actions against, then add the rest of your code (making sure to add checkpoints with the Checkpoint-Workflow at major steps). The following sample code will help you get started with the Azure connection:
$subName = 'SavillTech Internal Consumption' Connect-Azure -AzureConnectionName $subName Select-AzureSubscription -SubscriptionName $subName
- Once you runbook is complete, make sure to publish it so it's available.