1 min read

Azure – Migrate your AzureRM scripts to Az PowerShell

As you know, you have multiple ways to manage your Azure environment; through the portal (https://portal.azure.com), Cloud Shell (https://shell.azure.com/), Azure Cli, PowerShell modules…

Talking about the PowerShell module, you are probably aware that the AzureRM PowerShell modules are outdated (but still supported – for now) and have been replaced by the Az PowerShell modules.

That said, there are still lot of scripts out there still using this ‘old’ AzureRM modules.

Well, to help you migrating from AzureRM to Az modules, Microsoft has released an Az.Tools.Migration module to help you identify the scripts which can be migrated and then do the migration for you.

To take advantage of this AzureRM to Az Migration Toolkit, you need to:

  • Upgrade your AzureRM PowerShell modules to the latest version (6.13.1)using the commands

Update-Module -Name AzureRM -RequiredVersion 6.13.1

  • Then install the migration toolkit using the command

Install-Module -Name Az.Tools.Migration

image  image

Once the above steps have been completed, you can now start to generate your upgrade plan by using the New-AzUpgradeModulePlan command

New-AzUpgradeModulePlan -FromAzureRmVersion 6.13.1 -ToAzVersion 4.6.1 –DirectoryPath <location of your scripts> -OutVariable Plan (or any other variable name)

NOTE the Az version 4.6.1 is the latest available at the time of writing this post; in the future you will be able to update this version to use the latest one available at the time you run the command

image  image

You can review the results by exportin the content of the Plan variable.

You can also filter the results to review the script(s) with upgrade issues using the command

$Plan | Where-Object PlanResult -ne ReadyToUpgrade | Format-List

image

Once you have reviewed the results and isolated/updated the problematic script(s), you can now run the upgrade process using the command

NOTE if you have decided to isolate the problematic script(s) you will need to re run the upgrade plan command

Invoke-AzUpgradeModulePlan -Plan $Plan -FileEditMode SaveChangesToNewFiles -OutVariable Results (or any variable name)

image  image

Then you can review the upgrade results using the Results variable

$Results | Format-List

image

Your scripts are not updated; the upgrade process makes a copy of your script while updating the code; the file name is appended with _az_upgraded

image

Et voila, your AzureRM scripts are now migrated to use the Az module.

Azure – AzureRM PowerShell will be retired by Feb 29, 2024

As you know, you can manage your Azure resources using either the web portal (https://portal.azure.com) or command line tools (Azure PowerShell or...

Read More

Azure – A new PowerShell module is available to manage Azure Sentinel

You may now know Azure Sentinel, the cloud native SIEM (Security Information and Event Management) solution from Microsoft.

Read More

Exchange Online – Use the new Exchange Online PowerShell module v2 with Modern Authentication with your scripts (preview)

As you know, Microsoft is going to retire the basic authentication for Exchange Online PowerShell during the second half of 2021.

Read More