Share via

Error while changing AzureRm to Az Modules using Az migration toolkit.

Ramakrishna Abhijeet P 70 Reputation points
2023-08-22T15:18:15.94+00:00

I'm Trying to change AzureRm to Az Modules using Az migration toolkit but facing error while running below command with below error. I have installed AzureRM 6.13.1 and Az 10.2.0 running in PowerShell 5.1 version. Tried with different Az versions but same error until i use 9.3.0. But I couldn't get reason why it's failing for every version except for 9.3.0

 New-AzUpgradeModulePlan -FromAzureRmVersion 6.13.1 -ToAzVersion 10.2.0 -DirectoryPath "C:\Subscriptions" -OutVariable Plan
New-AzUpgradeModulePlan : Cannot validate argument on parameter 'ToAzVersion'. The argument "10.2.0" does not belong
to the set "9.3.0" specified by the ValidateSet attribute. Supply an argument that is in the set and then try the
command again.
At line:1 char:65
+ ... radeModulePlan -FromAzureRmVersion 6.13.1 -ToAzVersion 10.2.0 -Direct ...
+                                                            ~~~~~~
    + CategoryInfo          : InvalidData: (:) [New-AzUpgradeModulePlan], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,New-AzUpgradeModulePlan
Windows for business | Windows Server | User experience | PowerShell
0 comments No comments

Answer accepted by question author

Anonymous
2023-08-23T03:55:56.8566667+00:00

Hi,

The ValidateSetAttribute attribute specifies a set of possible values for a cmdlet parameter argument. For Az.Tools.Migration 1.1.4, the ToAzVersion parameter has a ValidateSet of '9.3.0' which means it can only accepet the value '9.3.0'.

You can check out the New-AzUpgradeModulePlan function here.

https://www.powershellgallery.com/packages/Az.Tools.Migration/1.1.4/Content/Functions%5CPublic%5CNew-AzUpgradeModulePlan.ps1

Best Regards,

Ian Xue


If the Answer is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

Was this answer helpful?

0 comments No comments

1 additional answer

Sort by: Most helpful
  1. SteveG 116 Reputation points
    2023-09-04T14:03:11.7766667+00:00

    According to comments block of the New-AzUpgradeModulePlan.ps1 script in the PowerShell Gallery, the latest version of the Az.Tools.Migration version 1.1.4 only supports Az module 9.3.0. From this I conclude that:

    1. If support for Az modules in addition to 9.3.0 were to be included, a new version of the migration tools module would be created. (If true - beware future readers of this comment and check the supported version of the New-AzUpgradeModulePlan.ps1 script!)
    2. The plan for script upgrades produced by this New-AzUpgradeModulePlan is only compatible with cmdlet calls for Az modules version 9.3.0, so the Az modules within our Azure environments will have to be upgraded (or in the OP's case downgraded) to this version for the plans to work, unless there is a guarantee that cmdlet calls are backwards compatible (or in the OP's case forwards compatible) which I doubt.
    3. If we are already using Az modules within our scripts (in addition to AzureRM) and the Az modules need to be upgraded we will have to re-test no only for changes from AzureRM calls to Az calls but also for changes to a newer version of the Az modules together with updating any dependencies that these modules require.

    Does this sound about right to you Ian?

    Steve G

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.