Octopus Deploy Documentation

Running Azure PowerShell

Last updated

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

These scripts typically rely on tools being available on the target worker.

We recommend that you provision your own tools on your worker - this way you can control what version of the tools are provisioned, and ensure their compatibility with the scripts you are trying to execute.

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.

Dynamic Worker Pools

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. You may need to create a new worker pool using one of the images that support execution containers.
  • Configure your step to run in an execution container, selecting a docker image that contains the versions of the Azure CLI or Azure Powershell cmdlets that you would like to use. For more information about selecting an image to use, see the Which Docker images can I use? section.

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

Need support? We're here to help.