Vscode Az Module Register Issue
Description:
When using Windows Powershell 5.1 and only in VSCode, running import-module az
results in many errors like:
1
2
Register-AzModule : The type initializer for 'Microsoft.Azure.Commands.Common.AzModule' threw an exception.
At C:\Users\myuser\Documents\WindowsPowerShell\Modules\Az.Advisor\2.0.0\Az.Advisor.psm1:49 char:13
Doesn’t seem to happen with native powershell console.
To Resolve:
-
I followed this issue and this issue to:
- Delete all AZ folders in my user Powershell Modules directory.
-
Download and install again =>
Install-Module -Name Az -RequiredVersion 9.6.0
- Then download the nupkg for Az.Accounts for
2.12.1
- Extract to the Az.Accounts subfolder under the version number.
-
Now when I run
Import-module az
, it works like in the past. My guess is this will continue to be an issue in the future and should probably switch to Powershell 7.
Comments