AzureRM PowerShell Commands that Don’t Exist when Enabling Compatibility Aliases in the Az Module

As I mentioned in a previous blog article, the AzureRM PowerShell module is only supported until December of 2020. It has been replaced by the Az PowerShell module which was introduced in December of 2018.

On Twitter, I recently asked if anyone was still using the AzureRM module and what was keeping them from transitioning to the Az module. One of the responses I received was due to the amount of work and time invested in scripts based on the AzureRM module.

The Az PowerShell module includes compatibility aliases for scripts written using the AzureRM PowerShell module. The compatibility aliases are enabled using the Enable-AzureRmAlias command. I decided to determine how compatible these so-called compatibility aliases are, at least from the standpoint of possibly missing commands altogether.

Since you can’t have both modules loaded at the same time in the same session, I decided to load the AzureRM module in Windows PowerShell 5.1 and the Az module in PowerShell 7.

First, I exported a list of all the commands in the AzureRM module to a CLI XML file.

After importing the Az PowerShell module into PowerShell 7, I stored the current aliases from the session in a variable and then ran the Enable-AzureRmAlias command.

Next, I compared the aliases before and after running the Enable-AzureRmAlias command and stored the results in another CLI XML file.

I compared the commands from the AzureRM module to the compatibility aliases added from the Az module using the previously exported XML files. 159 commands exist in the AzureRM module that don’t exist as aliases when enabling AzureRM compatibility aliases in the Az module.

I ran the same command again except this time exporting the results to another CLI XML file.

I switched back to Windows PowerShell since that’s where the AzureRM module is imported to determine what types of commands are missing. Based on the results, if you’re not currently following PowerShell best practices and using aliases from the AzureRM module in your PowerShell code, you’re out of luck with the compatibility aliases.

The majority of the missing commands are aliases from the AzureRM module, but there are also a few cmdlets missing.

While your existing PowerShell code probably doesn’t use these commands, it’s something to be aware of.

If you are using any of the AzureRM aliases in your PowerShell code, one alternative is to use PSScriptAnalyzer to automatically update the aliases to the actual cmdlet names. Since the AzureRM compatibility aliases are aliased to the new cmdlets in the Az module, PSScriptAnalyzer could also be used to automatically update your existing code to the new cmdlet names in the Az module.

µ

Leave a Reply

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

%d bloggers like this: