Chances are that, if you have started your journey to the cloud a while ago, and that’s not so long ago.. you already have IaaC – Infrastructure as a Code scripts and templates in place. I know I do and I know how important it is for Azure Cloud architecture and solutions to be maintained relevant and up to date.

Cloud deployments and solutions are never a fire-and-forget thing that you deploy once and you’ll never run into trouble. In fact, operations teams have to be more and more involved in turning and adjusting the knobs to keep everything running smoothly. Active monitoring, analyzing and troubleshooting skills becoming more important as we move from App Services to Kubernetes and micro-services .. from REST to Event-Driven .. from monolith to decoupled ..

Azure Az is the natural evolution of Azure PowerShell and is backward compatible with Azure RM.. but it’s not obviously so.

If you’re just setting up your machine now .. or if you’re upgrading ’cause .. why not? You’ll be installing:

Install-Module -Name Az

Microsoft Azure PowerShell – Cmdlets to manage resources in Azure. This module is compatible with WindowsPowerShell and PowerShell Core.

As indicated on Microsoft documentation: allows Azure PowerShell to run under PowerShell 5 on Windows or PowerShell 6 on any platform. The Az module is now the intended way to interact with Azure through PowerShell. AzureRM will continue to get bug fixes, but no longer receive new features.

So all my existing PowerShell scripts are written for AzureRM and therefore they just got a generous but clear end of life notice. In truth, it’s not that bad and I should resist the urge to keep an older version of AzureRM on just for these scripts. Remember that Azure is also being updated so keeping up is paramount. Microsoft has been hard at work to make this as smooth a transition as possible and it has indeed. The documentation has never been better: Migrate from AzureRM to Azure PowerShell Az

However, in my experience, enabling compatibility is not enough. Also, Microsoft recommends that you uninstall all AzureRM powershell versions when installing the new Azure Az module. Uninstall can either be a straightforward call in PowerShell with elevated priviledges:

Uninstall-AzureRM

or if that fails, straight on uninstall “Azure PowerShell” from Add-Remove Programs. Detailed instructions on the Microsoft docs again.

Once you have a clean installation of the new Azure PowerShell, make sure you enable the compatibility mode:

Enable-AzureRmAlias -Scope CurrentUser

As I am the only user on my machine, I’ll run this without a scope as I will not affect anyone else. It’s important because AzureRM should no longer be on the system as enabling compatibility while AzureRM is still present may result in unpredictable behavior.

To execute my existing scripts I had to enable the Azure RM alias and then authenticate or import the Account module as the

Login-AzureRmAccount

would fail with:

"command was found in the module but the module could not be loaded. For more information, run 'Import-Module <ModuleName>."

Running the suggested command would resolve the issue provided that I’m checking for an authenticated account in my script and don’t try to execute the RM login command again while authenticated.

I also tried authenticating with the new az command and that would solve the issue as well, under the assumption stated above. The new command being:

Connect-AzAccount

 

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply