AzureRM PowerShell Commands that Don’t Exist when Enabling Compatibility Aliases in the Az Module
On Twitter, I asked if anyone was still using the AzureRM PowerShell module and what was keeping them from transitioning to the Az PowerShell module. One of the responses I received was because of 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.
1Import-Module -Name AzureRM
2Get-Command -Module AzureRM.* |
3Export-Clixml -Path C:\tmp\azurerm.xml
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.
1Import-Module -Name Az
2$PreAlias = Get-Alias
3Enable-AzureRmAlias
Next, I compared the aliases before and after running the Enable-AzureRmAlias
command and stored
the results in another CLI XML file.
1Compare-Object -ReferenceObject $PreAlias -DifferenceObject (Get-Alias) -Property Name |
2Export-Clixml -Path C:\tmp\az.xml
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.
1Compare-Object -ReferenceObject (Import-Clixml -Path C:\tmp\azurerm.xml) -DifferenceObject (Import-Clixml -Path C:\tmp\az.xml) -Property Name |
2Where-Object SideIndicator -eq '<='
I ran the same command again except this time exporting the results to another CLI XML file.
1Compare-Object -ReferenceObject (Import-Clixml -Path C:\tmp\azurerm.xml) -DifferenceObject (Import-Clixml -Path C:\tmp\az.xml) -Property Name |
2Where-Object SideIndicator -eq '<=' |
3Export-Clixml -Path C:\tmp\azure-diff.xml
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.
1Import-Clixml -Path C:\tmp\azure-diff.xml |
2Select-Object -Property Name |
3Get-Command
The majority of the missing commands are aliases from the AzureRM module, but there are also a few cmdlets missing.
1Import-Clixml -Path C:\tmp\azure-diff.xml |
2Get-Command |
3Group-Object -Property CommandType -NoElement
While your existing PowerShell code probably doesn't use these commands, it's something to be aware of.
1Import-Clixml -Path C:\tmp\azure-diff.xml |
2Get-Command |
3Where-Object CommandType -eq Cmdlet |
4Sort-Object -Property Source, Name
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.
µ