How to update Azure PowerShell modules in Azure Automation
The most common Azure PowerShell modules are provided by default in each Automation account. The Azure team updates the Azure modules regularly. In your Automation account, you're provided a way to update the modules in the account when new versions are available from the portal.
Because modules are updated regularly by the product group, changes can occur with the included cmdlets. This action may negatively impact your runbooks depending on the type of change, such as renaming a parameter or deprecating a cmdlet entirely. To avoid impacting your runbooks and the processes they automate, test and validate before proceeding. 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. After the results are validated and you've applied any changes required, you can move the changes to production.
A new Automation account might not contain the latest modules.
Updating Azure Modules
In the Modules page of your Automation account, there's an option called Update Azure Modules. It's always enabled.
Before updating your Azure modules it's recommended that you update them in a test Automation Account to ensure that your existing scripts work as expected before updating your Azure modules.
Click Update Azure Modules, a confirmation notification is shown that asks if you want to continue.
Click Yes and the module update process begins. The update process takes about 15-20 minutes to update the following modules:
If the modules are already up-to-date, then the process completes in a few seconds. When the update process completes, you're notified.
The .NET core AzureRm modules (AzureRm.*.Core) aren't supported in Azure Automation and can't be imported.
Azure Automation uses the latest modules in your Automation account when a new scheduled job is run.
If you use cmdlets from these Azure PowerShell modules in your runbooks, you want to run this update process every month or so to make sure that you have the latest modules. Azure Automation uses the
AzureRunAsConnection connection to authenticate when updating the modules. If the service principal is expired or no longer exists on the subscription level, the module update will fail.
Alternative ways to update your modules
As mentioned, the Update Azure Modules button isn't available in the sovereign clouds, it's only available in the global Azure cloud. This is due to the fact that the latest version of the Azure PowerShell modules from the PowerShell Gallery may not work with the Resource Manager resources currently deployed in these clouds.
You can import and run the Update-AzureModule.ps1 runbook to attempt to update the Azure modules in your Automation Account. This process may fail if the versions you are trying to import from the gallery are not be compatible with the Azure services currently deployed to the target Azure Environment. This may require you to ensure the compatible versions of modules are specified in the runbook parameters.
AzureRmEnvironment parameter to pass the correct environment to the runbook. Acceptable values are AzureCloud, AzureChinaCloud, AzureGermanCloud, and AzureUSGovernmentCloud. These values can be obtained from using
Get-AzureRmEnvironment | select Name. If you don't pass a value to this parameter, the runbook will default to the Azure public cloud AzureCloud
If you want to use a specific Azure PowerShell module version instead of the latest available on the PowerShell Gallery, pass these versions to the optional
ModuleVersionOverrides parameter of the Update-AzureModule runbook. For examples, see the Update-AzureModule.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 as the Update Azure Modules button.
- To learn more about Integration Modules and how to create custom modules to further integrate Automation with other systems, services, or solutions, see Integration Modules.