Running AZ CLI commands from Azure Powershell steps

sam.mckenzie's Avatar


06 Dec, 2017 08:57 AM

I've got a project at the moment that involves provisioning and tearing down web apps. One of the main aspects of this is to include MSI (Managed Service Identity) in the web app provisioning.

I know we can do this with ARM templates and already have that working. But there are other steps we require that can't be done in ARM. And although this can be achieved using multiple methods, we are trying to keep the process as simple as possible and using the same method in effect (where possible).

Everything we need to do seems to be possible using the az cli, but I have been unable to find any way or reference of getting Octopus to execute it. The closets I've seen is And have a similar setup, but still get "The term 'az' is not recognized as the name of a cmdlet" when running. The commands however execute fine from the server itself.
I've also looked at using Octopus.Action.Azure.UseBundledAzurePowerShellModules option but this hasn't worked either.

Has anyone had any success getting az cli to work and am I missing something obvious? It's not going to prevent us on what we are doing but keeping to one method would be really helpful.

Many thanks for any assistance

  1. Support Staff 1 Posted by Lawrence Wilson on 07 Dec, 2017 01:18 AM

    Lawrence Wilson's Avatar

    Hi Sam,
    Thanks for reaching out! I'm sorry to hear you're running into issues while executing azure cli (az) commands from Octopus.

    To test this out for you I spun up a blank Azure VM running Windows Server 2016, connected it to Octopus and attempted to run a script step template calling az on a tentacle. After installing the Azure CLI 2.0 and rebooting the Tentacle this all worked fine.

    In order for me to get this going I needed to ensure the following requirements were met:

    • The Tentacle should be rebooted after Azure CLI is installed to be sure that the environment variable path is set properly. (This would allow the tentacle to execute az from anywhere in Windows)

    • I chose the "Run a Script" step template and specified PowerShell as the language to run the script

    • I needed to ensure that the Execution Plan is set to "Deployment targets" to ensure that this is indeed running on the tentacle rather than the Octopus server.

    Please let me know if you have any further questions. I look forward to hearing if this has been helpful for you.

    Kind regards,

  2. 2 Posted by sam.mckenzie on 07 Dec, 2017 09:08 AM

    sam.mckenzie's Avatar

    Hi Lawrence, Thanks for getting back to me.

    You are indeed correct. A restart of the services (or server in this case as we did updates on it) fixed the issue. Feel a little silly for not thinking of that first :)

    Kind regards


  3. Support Staff 3 Posted by Lawrence Wilson on 08 Dec, 2017 08:49 AM

    Lawrence Wilson's Avatar

    Hi Sam,
    Thanks for keeping in touch! I'm glad to hear that you have resolved this issue!

    Kind regards,

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac