How to Install the Azure Az PowerShell Module

The Az PowerShell module was released in December of 2018 and is now the recommended module for managing Microsoft Azure. AzureRM is the previous PowerShell module for managing Azure which has been deprecated but will continue to be supported until December of 2020.

Windows PowerShell 5.1, PowerShell Core 6, PowerShell 7, and higher are supported by the Az PowerShell module. Windows 10 version 1607 and higher has Windows PowerShell 5.1 installed by default.

Determine if the version of PowerShell you’re running meets the minimum requirements before attempting to install the Az PowerShell module.

The .NET Framework 4.7.2 or higher is also required by the Az PowerShell module on Windows. The version of the .NET Framework needs to be verified prior to installing the Az PowerShell module because Windows PowerShell 5.1 only requires the .NET Framework 4.5 or higher.

Verify the .NET Framework 4.7.2 or higher is installed.

Previously there were full and client versions of the NET Framework, but beginning with .NET Framework 4.5, the client version was discontinued so there’s no longer a reason to check both registry entries.

The installation itself is simple from the PowerShell Gallery.

The previous command will install the Az module for all users and requires admin rights. The official Microsoft documentation recommends only installing it for the current user by specifying the Scope parameter with CurrentUser as its value which does not require admin rights.

The official Microsoft documentation also states that you can’t have both the AzureRM and Az PowerShell modules installed for Windows PowerShell 5.1 at the same time. Their recommendation is to install the Az module for PowerShell Core 6 or PowerShell 7 if you already have the AzureRM module installed for Windows PowerShell.

Install them both in Windows PowerShell at your own risk!

Clearly, you can have them both installed at the same time as shown in the following example.

While they didn’t specify why, many assume that it’s due to the ability to enable AzureRM aliases in the Az module for backwards compatibility. That conclusion is completely fabricated and isn’t a factor due to the way command precedence works in PowerShell. If commands with the same name exist, alias are executed first, followed by functions, cmdlets, and then native Windows commands.

Let’s see what happens when I have both modules installed and enable AzureRM aliases in the Az PowerShell module.

Notice that although I have both modules installed, when I execute an AzureRM command, it actually executes the command in the Az module via its alias instead of the command in the AzureRM module.

If the AzureRM module is imported first, an error will be generated when you try to import the Az module.

If you attempt to import the AzureRM module after the Az module, a different error is generated.

Removing the module within the same session and then trying to import the other one doesn’t clear up the problem either. If you are going to have both installed for some reason in Windows PowerShell, you’ll either need to close and reopen your PowerShell session when switching between the two or have two separate sessions open.

If you no longer need the AzureRM module, you always have the option of de-installing it as referenced in one of the previous error messages. If you don’t use the Uninstall-AzureRm command and decide to use another method to de-install the AzureRM module, be sure to also remove the other 53 modules that it installs.

Microsoft articles containing addition information:

Be sure to read my previous blog article “Setting Dependencies on the Azure PowerShell Module” which shows that the Az module is simply a wrapper containing 54 PowerShell modules for individual Azure products.

µ

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: