Use Azure AZ Modules from Octopus Server

Hello Team,

As Microsoft has recently moved to AZ Modules and few of the fixes which didn’t came to RM modules, it’s available in AZ modules now. We would like to start migrating our Azure RM scripts which is used in Octopus Deploy to AZ. We are running the Octopus deploy on our VM (Self Hosted). Current Octopus Deploy version is v2019.9.10 LTS.

I have few queries before we start migrating the scripts!

  1. As microsoft suggests we can’t have both AZ and RM module installed on same machine, if we need to migrate, we need to remove the RM module and install AZ module on Octopus Server. But when we are using it in Octopus from Step template, it’s having only on parent template (Built-in) which is “Run an Azure Powershell script” from where we put our custom Azure PowerShell script, but how does it authenticate with AZ commands from the Service Principals? Do we need to make any explicit changes to work with AZ commands?

  2. Moreover in other octopus support forms, there were few mentions like we need to install the AZ command scoped to CurrentUser? Can’t we scope it to “AllUsers”?

  3. Is there any documentation for using AZ scripts from Octopus Deploy? It would be very helpful for us to start migrating.


Hi @karthik623521,

Thanks for getting in touch!

As we haven’t fully made the switch to AZ from RM we don’t have any significant documentation available for this at the moment.

We do have a workaround that will allow you to make use of the AZ module though.

First you need to disable the use of the bundled Azure modules, you can do this by setting the following variable:

OctopusUseBundledAzureModules = False

That will then fall back to the Azure modules that you have installed on your system (either AzureRM or AZ). If you are using AZ you will then need to enable AzureRM Alias’s in AZ. In an admin powershell session run the following command:

Enable-AzureRmAlias -Scope LocalMachine

As using the AZ module hasn’t been internally tested you may run into odd issues that require steps such as scoping the command to the CurrentUser. The best advice I can offer is to use it how you would prefer initially and only go down those routes if you encounter problems.

I hope this helps, please let me know if you have any further questions.

Best regards,

1 Like

Thank you Paul! Let me try to do that and see if that works!

Have a great day!

1 Like