Last Update: Sep 04, 2024 | Published: Aug 14, 2017
In this post, I will explain how you can use the Azure Portal to deploy Azure Automation, install additional PowerShell modules, and ensure that all PowerShell modules are up to date.
As always with an Azure “how to” post, Microsoft will probably change the user interface/steps as soon as this post is submitted. The changes will probably be minor, so you should be still able to get through the process with this guide.
Unfortunately, some of the nomenclature in Azure Automation is confusing. An Automation Account is a bucket/engine for storing/running automation runbooks (scripts). It is not actually a user account in the way that the name would suggest!
Creating an Automation Account is pretty simple. Note that Automation is only available in some of the Azure regions but this has no impact on where you can use Automation. For example, I can deploy Azure Automation in one region and execute runbooks against resources in another region.
Log into the Azure Portal, expand the navigation bar, search for Automation, select Automation Accounts, and then click Add. Enter the following details:
A new Azure Automation Account and some sample runbooks are created in your selected resource group/region after a couple of moments.
I have found in the past that Automation Accounts can be deployed by Azure with out-of-date PowerShell modules. That is not great because this will prevent Azure PowerShell-based runbooks from executing correctly or at all. However, we can easily update the modules.
Open the new Automation Account and click Modules. Here, you will find the modules that are installed by default and the last modified date. You can quickly update all of the currently installed Azure PowerShell modules by clicking the Update Azure Modules button. This process can take a little while, so Microsoft will ask if you are sure. Click Yes to continue.
The update process launches an Automation job. Click Jobs and expand the running instance of Update-AutomationAzureModulesForAccount. You can track the progress of this job by clicking Output.
I created a brand-new Automation Account to create screenshots for this article. Over half of the modules were updated by the above process, so this is a don’t-skip-it-step.
In the past, I have written PowerShell runbooks that require Azure PowerShell modules to be added to the default set. This has included AzureRM.Network for configuring network configurations during Azure Site Recovery failovers. You will know which modules are required, when you try to test that your runbook and cmdlets are identified as being unknown.
Do the following to add an Azure PowerShell module, open the Automation Account and browse to Modules Gallery. Search for the missing module and select it. Click the Import button and then click OK in the Import blade if you wish to continue. Note that some modules might identify other modules that must be imported before the desired one is imported.
It can take several minutes for an import to complete. You can track the progress of the import job by returning to Modules in the Automation Account and monitoring the status of the new module.
There are three pricing tiers for Azure Automation:
A new Automation Account is deployed into the free tier. You can switch the tier to Basic if you require more than 500 minutes of runbook runtime or OMS if you purchase that bundle. To do this:
You now should be ready to use your Automation Account.