title | description | services | ms.subservice | ms.date | ms.topic |
---|---|---|---|---|---|
Update Azure PowerShell modules in Azure Automation |
This article tells how to update common Azure PowerShell modules provided by default in Azure Automation. |
automation |
process-automation |
06/14/2019 |
conceptual |
The most common PowerShell modules are provided by default in each Automation account. See Default modules. As the Azure team updates the Azure modules regularly, changes can occur with the included cmdlets. These changes, for example, renaming a parameter or deprecating a cmdlet entirely, can negatively affect your runbooks.
Note
You can't delete global modules, which are modules that Automation provides out of the box.
To avoid impacting your runbooks and the processes they automate, be sure to test and validate as you make updates. If you don't have a dedicated Automation account intended for this purpose, consider creating one so that you can test many different scenarios during the development of your runbooks. This testing should include iterative changes, such as updating the PowerShell modules.
Make sure that your Automation account has an Azure Run As account credential created.
If you develop your scripts locally, it's recommended to have the same module versions locally that you have in your Automation account when testing to ensure that you receive the same results. After the results are validated and you've applied any changes required, you can move the changes to production.
Note
A new Automation account might not contain the latest modules.
To update the Azure modules in your Automation account, you must use the Update-AutomationAzureModulesForAccount runbook, which is available as open source. To start using this runbook to update your Azure modules, download it from the GitHub repository. You can then import it into your Automation account or run it as a script. To learn how to import a runbook in your Automation account, see Import a runbook.
The Update-AutomationAzureModulesForAccount runbook supports updating the Azure, AzureRM, and Az modules by default. Review the Update Azure modules runbook README for more information on updating Az.Automation modules with this runbook. There are additional important factors that you need to take into account when using the Az modules in your Automation account. To learn more, see Manage modules in Azure Automation.
You can use the runbook code as a regular PowerShell script instead of a runbook. To do this, sign in to Azure using the Connect-AzAccount cmdlet first, then pass -Login $false
to the script.
To use this runbook on sovereign clouds, use the AzEnvironment
parameter to pass the correct environment to the runbook. Acceptable values are AzureCloud (Azure public cloud), AzureChinaCloud, AzureGermanCloud, and AzureUSGovernment. These values can be retrieved using Get-AzEnvironment | select Name
. If you don't pass a value to this cmdlet, the runbook defaults to AzureCloud.
If you want to use a specific Azure PowerShell module version instead of the latest module available on the PowerShell Gallery, pass these versions to the optional ModuleVersionOverrides
parameter of the Update-AutomationAzureModulesForAccount runbook. For examples, see the Update-AutomationAzureModulesForAccount.ps1 runbook. Azure PowerShell modules that aren't mentioned in the ModuleVersionOverrides
parameter are updated with the latest module versions on the PowerShell Gallery. If you pass nothing to the ModuleVersionOverrides
parameter, all modules are updated with the latest module versions on the PowerShell Gallery. This behavior is the same for the Update Azure Modules button in the Azure portal.
- For details of using modules, see Manage modules in Azure Automation.
- For information about the update runbook, see Update Azure modules runbook.