Running Azure PowerShell

Octopus can help you to run scripts on targets within Microsoft Azure.

These scripts typically rely on tools being available when they execute.

It is best that you control the version of these tools - your scripts will rely on a specific version that they are compatible with to function correctly.

The easiest way to achieve this is to use an execution container for your script step.

If this is not an option in your scenario, we recommend that you provision your own tools on your worker.

Using the Azure tools bundled with Octopus Deploy is not recommended. Octopus bundles versions of the Azure Resource Manager Powershell modules (AzureRM) and Azure CLI. These were originally provided as convenience mechanisms for users wanting to run scripts against Azure targets. The versions bundled are now out of date, and we will not be updating them further.

From Octopus 2021.2, a warning will also appear in the deployment logs if the Azure tools bundled with Octopus Deploy are used in a step.

We recommend you configure Octopus Deploy to use your own version of the Azure PowerShell cmdlets and version of the Azure CLI.

When executing PowerShell against Azure, Octopus Deploy will automatically use your configured Azure account details to authenticate you into the AzureRM PowerShell modules, the Azure PowerShell modules, and Azure CLI tools, if they exist on the worker executing the script.

This applies to:

This functionality requires the Azure CLI version 2.0 or above to be installed on the worker.

Choosing the right Azure account type

Azure supports two authentication methods, each of which provides access to a different set of Azure APIs:

Learn more about configuring the right Azure Account.

Running Scripts in Octopus Cloud

Octopus Cloud uses a special type of worker pool called a Dynamic Worker Pool. Octopus provides these, and you cannot easily install custom versions of the Azure tools on them.

To use your own version of the Azure CLI or Azure Powershell cmdlets when using Dynamic Worker Pools, please do the following:

  • Configure your step to use a Dynamic Worker pool that supports execution containers.
  • Configure your step to run in an execution container with a compatible docker image that contains the versions of the Azure CLI or Azure Powershell cmdlets that you would like to use.

Run an Azure PowerShell script step

Octopus Deploy provides a Run an Azure PowerShell Script step type, for executing PowerShell in the context of an Azure Subscription. For information about adding a step to the deployment process, see the add step section.

Learn more

Help us continuously improve

Please let us know if you have any feedback about this page.

Send feedback

Page updated on Sunday, January 1, 2023