vscode-powershell
vscode-powershell copied to clipboard
Unable to load Az modules - Assembly with same name is already loaded
Prerequisites
- [X] I have written a descriptive issue title.
- [X] I have searched all open and closed issues to ensure it has not already been reported.
- [X] I have read the troubleshooting guide.
- [X] I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
- [X] I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
- [X] If this is a security issue, I have read the security issue reporting guidance.
Summary
If you load a PowerShell file that has references to Azure PowerShell commands the assemblies are being loaded without loading the module fully.
This is repeat of #3012 which was closed with no solution. Extensions do not matter in this case, it is when a file that has Azure module references is opened the assemblies get loaded but not the actual modules.
PowerShell Version
> $PSVersionTable
Name Value
---- -----
PSVersion 7.2.13
PSEdition Core
GitCommitId 7.2.13
OS Darwin 21.6.0 Darwin Kernel Version 21.6.0: Thu Jul 6 22:20:00 PDT 2023; root:xnu-8020.240.18.702.13~1/RELEASE_A…
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visual Studio Code Version
> code-insiders --version
1.82.0-insider
f1302be1e67e3af5fbeb8bbb2ea784de7bc96150
arm64
Extension Version
> code --list-extensions --show-versions | Select-String powershell
[email protected]
Steps to Reproduce
- Close all PowerShell files
- Restart session for PowerShell Extension
- Run following command to list loaded assemblies
[System.AppDomain]::CurrentDomain.GetAssemblies() | Where-Object Location | Sort-Object -Property FullName | Select-Object -Property FullName, Location, GlobalAssemblyCache, IsFullyTrusted | Where FullName -like '*azure*' | ft
- Note nothing is returned
- Run
Get-Module Az*
- Nothing is returned
- Open file (any file) with Az PowerShell references
- Rerun step 3
- All assemblies for the Az.Accounts and related commands are loaded
- Rerun step 5
- Nothing is returned
- Run
Import-Module Az.Accounts
- Error returned:
Import-Module: Assembly with same name is already loaded
Visuals
https://github.com/PowerShell/vscode-powershell/assets/11204251/113bb121-5cd8-482d-847b-184bb594cb84
Logs
Thanks @wsmelton , to clarify is this a new issue for you or has this been happening on previous versions of the extension?
"If you load a PowerShell file that has references to Azure PowerShell commands the assemblies are being loaded without loading the module fully." We think this is happening from a Get-Help
call in tab completion
It looks like the error itself may be coming from our resolve handler or something similar
Always happening since I started using an Apple device (M1), switched to this month ago. I can't recall if Windows device gives me this issue...I can test that shortly.
Extension versions I tried v2023.6.0
back to v2023.3.3
, issue exist in all of them.
So I cannot replicate this on Windows (Windows 10, VS Code Insiders, PowerShell 7.2, and v2023.9.1
).
Well, that's interesting. Usually it's the other way around (issue occurs on Windows but nowhere else).
I'll grab diagnostic logs for the windows device I used tomorrow and upload them.
@wsmelton could you share your PSSA settings file? We noticed:
2023-09-05 08:05:03.512 -05:00 [VRB] Using Script Analyzer settings path - '/Users/smelton/ldx/Agents/ScriptAnalyzerSettings.psd1'.
and believe there is a PSSA rule that can cause modules to be imported when analyzing the file.
There is no PSSA settings file in the referenced project
We have this in most of the project's settings.json file:
"powershell.scriptAnalysis.settingsPath": "./ScriptAnalyzerSettings.psd1"
Your log said it loaded '/Users/smelton/ldx/Agents/ScriptAnalyzerSettings.psd1', is there anything in that file? Could be a bug that it found it but might be what's going on.
Oh wait nevermind also in the log:
[INF] Unable to find PSSA settings file at '/Users/smelton/ldx/Agents/ScriptAnalyzerSettings.psd1'. Loading default rules.
And I misread that earlier.
- Open file (any file) with Az PowerShell references
@wsmelton Could you share a script you know to cause this issue? I have an M1 Mac available I can try to reproduce this on. If I can repro it, there's a really good chance I can fix it.
So seems after updates (whether the extension pre-release or VS Code Insiders) I no longer see this issue. At least the steps I have written no longer show any errors.
@wsmelton...well, that's confusing, but good to know! Let us know if it crops up again. Thanks!
Hi, I got the same problem as @wsmelton. Running Windows 10 Enterprise 22H2 the same problem occurs with both release and pre-release versions of the PowerShell-extension:
PS C:\> Import-Module Az.Keyvault -Verbose
VERBOSE: Loading module from path 'C:\Users\*********\Documents\PowerShell\Modules\Az.Keyvault\4.11.0\Az.Keyvault.psd1'.
VERBOSE: Loading 'Assembly' from path 'C:\Users\*********\Documents\PowerShell\Modules\Az.Keyvault\4.11.0\Microsoft.Azure.KeyVault.dll'.
VERBOSE: Loading 'Assembly' from path 'C:\Users\*********\Documents\PowerShell\Modules\Az.Keyvault\4.11.0\Microsoft.Azure.KeyVault.WebKey.dll'.
VERBOSE: Loading 'Assembly' from path 'C:\Users\*********\Documents\PowerShell\Modules\Az.Keyvault\4.11.0\Microsoft.Azure.PowerShell.KeyVault.Management.Sdk.dll'.
VERBOSE: Loading 'Assembly' from path 'C:\Users\*********\Documents\PowerShell\Modules\Az.Keyvault\4.11.0\Azure.Security.KeyVault.Keys.dll'.
VERBOSE: Loading 'Assembly' from path 'C:\Users\*********\Documents\PowerShell\Modules\Az.Keyvault\4.11.0\Azure.Security.KeyVault.Certificates.dll'.
VERBOSE: Loading 'Assembly' from path 'C:\Users\*********\Documents\PowerShell\Modules\Az.Keyvault\4.11.0\Azure.Security.KeyVault.Administration.dll'.
VERBOSE: Loading 'Assembly' from path 'C:\Users\*********\Documents\PowerShell\Modules\Az.Keyvault\4.11.0\BouncyCastle.Crypto.dll'.
VERBOSE: Loading 'Assembly' from path 'C:\Users\*********\Documents\PowerShell\Modules\Az.Keyvault\4.11.0\KeyVault.Autorest\bin\Az.KeyVault.private.dll'.
VERBOSE: Loading 'FormatsToProcess' from path 'C:\Users\*********\Documents\PowerShell\Modules\Az.Keyvault\4.11.0\KeyVault.format.ps1xml'.
VERBOSE: Loading 'FormatsToProcess' from path 'C:\Users\*********\Documents\PowerShell\Modules\Az.Keyvault\4.11.0\KeyVault.Autorest\Az.KeyVault.format.ps1xml'.
VERBOSE: Populating RepositorySourceLocation property for module Az.Keyvault.
VERBOSE: Loading module from path 'C:\Users\*********\Documents\PowerShell\Modules\Az.Keyvault\4.11.0\Az.KeyVault.Extension\Az.KeyVault.Extension.psd1'.
VERBOSE: Importing function 'Get-Secret'.
VERBOSE: Importing function 'Get-SecretInfo'.
VERBOSE: Importing function 'Remove-Secret'.
VERBOSE: Importing function 'Set-Secret'.
VERBOSE: Importing function 'Test-SecretVault'.
VERBOSE: Loading module from path 'C:\Users\*********\Documents\PowerShell\Modules\Az.Keyvault\4.11.0\KeyVault.Autorest\Az.KeyVault.psm1'.
Import-Module: Assembly with same name is already loaded
Write-Error:
This module requires Az.Accounts version 2.7.5 or greater. For installation instructions, please see: https://learn.microsoft.com/powershell/azure/install-az-ps
Import-Module: The module to process 'C:\Users\*********\Documents\PowerShell\Modules\Az.Keyvault\4.11.0\KeyVault.Autorest\Az.KeyVault.psm1', listed in field 'NestedModules' of module manifest 'C:\Users\*********\Documents\PowerShell\Modules\Az.Keyvault\4.11.0\Az.Keyvault.psd1' was not processed because no valid module was found in any module directory.```
However, when I open a new terminal in VS Code using profile 'pwsh', the problem does not occur:
PS C:\> Import-Module Az.KeyVault -Verbose
VERBOSE: Loading module from path 'C:\Users\*********\Documents\PowerShell\Modules\Az.KeyVault\4.11.0\Az.KeyVault.psd1'.
VERBOSE: Loading 'Assembly' from path 'C:\Users\*********\Documents\PowerShell\Modules\Az.KeyVault\4.11.0\Microsoft.Azure.KeyVault.dll'.
VERBOSE: Loading 'Assembly' from path 'C:\Users\*********\Documents\PowerShell\Modules\Az.KeyVault\4.11.0\Microsoft.Azure.KeyVault.WebKey.dll'.
VERBOSE: Loading 'Assembly' from path 'C:\Users\*********\Documents\PowerShell\Modules\Az.KeyVault\4.11.0\Microsoft.Azure.PowerShell.KeyVault.Management.Sdk.dll'.
VERBOSE: Loading 'Assembly' from path 'C:\Users\*********\Documents\PowerShell\Modules\Az.KeyVault\4.11.0\Azure.Security.KeyVault.Keys.dll'.
VERBOSE: Loading 'Assembly' from path 'C:\Users\*********\Documents\PowerShell\Modules\Az.KeyVault\4.11.0\Azure.Security.KeyVault.Certificates.dll'.
VERBOSE: Loading 'Assembly' from path 'C:\Users\*********\Documents\PowerShell\Modules\Az.KeyVault\4.11.0\Azure.Security.KeyVault.Administration.dll'.
VERBOSE: Loading 'Assembly' from path 'C:\Users\*********\Documents\PowerShell\Modules\Az.KeyVault\4.11.0\BouncyCastle.Crypto.dll'.
VERBOSE: Loading 'Assembly' from path 'C:\Users\*********\Documents\PowerShell\Modules\Az.KeyVault\4.11.0\KeyVault.Autorest\bin\Az.KeyVault.private.dll'.
VERBOSE: Loading 'FormatsToProcess' from path 'C:\Users\*********\Documents\PowerShell\Modules\Az.KeyVault\4.11.0\KeyVault.format.ps1xml'.
VERBOSE: Loading 'FormatsToProcess' from path 'C:\Users\*********\Documents\PowerShell\Modules\Az.KeyVault\4.11.0\KeyVault.Autorest\Az.KeyVault.format.ps1xml'.
VERBOSE: Populating RepositorySourceLocation property for module Az.KeyVault.
VERBOSE: Loading module from path 'C:\Users\*********\Documents\PowerShell\Modules\Az.KeyVault\4.11.0\Az.KeyVault.Extension\Az.KeyVault.Extension.psd1'.
VERBOSE: Loading module from path 'C:\Users\*********\Documents\PowerShell\Modules\Az.KeyVault\4.11.0\Az.KeyVault.Extension\Az.KeyVault.Extension.psm1'.
VERBOSE: Exporting function 'Check-SubscriptionLogIn'.
VERBOSE: Exporting function 'Get-Secret'.
VERBOSE: Exporting function 'Get-ByteArray'.
VERBOSE: Exporting function 'Get-String'.
VERBOSE: Exporting function 'Get-SecureString'.
VERBOSE: Exporting function 'Get-PSCredential'.
VERBOSE: Exporting function 'Get-Hashtable'.
VERBOSE: Exporting function 'Set-Secret'.
VERBOSE: Exporting function 'Set-ByteArray'.
VERBOSE: Exporting function 'Set-String'.
VERBOSE: Exporting function 'Set-SecureString'.
VERBOSE: Exporting function 'Set-PSCredential'.
VERBOSE: Exporting function 'Set-Hashtable'.
VERBOSE: Exporting function 'Remove-Secret'.
VERBOSE: Exporting function 'Get-SecretInfo'.
VERBOSE: Exporting function 'Test-SecretVault'.
VERBOSE: Importing function 'Get-Secret'.
VERBOSE: Importing function 'Get-SecretInfo'.
VERBOSE: Importing function 'Remove-Secret'.
VERBOSE: Importing function 'Set-Secret'.
VERBOSE: Importing function 'Test-SecretVault'.
VERBOSE: Loading module from path 'C:\Users\*********\Documents\PowerShell\Modules\Az.KeyVault\4.11.0\KeyVault.Autorest\Az.KeyVault.psm1'.
VERBOSE: Importing function 'Add-AzKeyVaultManagedHsmRegion'.
VERBOSE: Importing function 'Get-AzKeyVaultManagedHsmRegion'.
VERBOSE: Importing function 'Remove-AzKeyVaultManagedHsmRegion'.
VERBOSE: Importing function 'Test-AzKeyVaultManagedHsmNameAvailability'.
VERBOSE: Importing function 'Test-AzKeyVaultNameAvailability'.
VERBOSE: Loading module from path 'C:\Users\*********\Documents\PowerShell\Modules\Az.KeyVault\4.11.0\Az.KeyVault.psm1'.
VERBOSE: Exporting function 'Get-Secret'.
VERBOSE: Exporting function 'Get-SecretInfo'.
VERBOSE: Exporting function 'Remove-Secret'.
VERBOSE: Exporting function 'Set-Secret'.
VERBOSE: Exporting function 'Test-SecretVault'.
VERBOSE: Exporting function 'Add-AzKeyVaultManagedHsmRegion'.
VERBOSE: Exporting function 'Get-AzKeyVaultManagedHsmRegion'.
VERBOSE: Exporting function 'Remove-AzKeyVaultManagedHsmRegion'.
VERBOSE: Exporting function 'Test-AzKeyVaultManagedHsmNameAvailability'.
VERBOSE: Exporting function 'Test-AzKeyVaultNameAvailability'.
VERBOSE: Exporting function 'Test-DotNet'.
VERBOSE: Exporting function 'Preload-Assembly'.
VERBOSE: Exporting cmdlet 'Add-AzKeyVaultCertificate'.
VERBOSE: Exporting cmdlet 'Backup-AzKeyVaultCertificate'.
VERBOSE: Exporting cmdlet 'Add-AzKeyVaultCertificateContact'.
VERBOSE: Exporting cmdlet 'Get-AzKeyVaultCertificateContact'.
VERBOSE: Exporting cmdlet 'Remove-AzKeyVaultCertificateContact'.
VERBOSE: Exporting cmdlet 'Get-AzKeyVaultCertificate'.
VERBOSE: Exporting cmdlet 'Get-AzKeyVaultCertificateOperation'.
VERBOSE: Exporting cmdlet 'Import-AzKeyVaultCertificate'.
VERBOSE: Exporting cmdlet 'Get-AzKeyVaultCertificateIssuer'.
VERBOSE: Exporting cmdlet 'Remove-AzKeyVaultCertificateIssuer'.
VERBOSE: Exporting cmdlet 'Set-AzKeyVaultCertificateIssuer'.
VERBOSE: Exporting cmdlet 'New-AzKeyVaultCertificatePolicy'.
VERBOSE: Exporting cmdlet 'Set-AzKeyVaultCertificatePolicy'.
VERBOSE: Exporting cmdlet 'Remove-AzKeyVaultCertificate'.
VERBOSE: Exporting cmdlet 'Remove-AzKeyVaultCertificateOperation'.
VERBOSE: Exporting cmdlet 'Restore-AzKeyVaultCertificate'.
VERBOSE: Exporting cmdlet 'Stop-AzKeyVaultCertificateOperation'.
VERBOSE: Exporting cmdlet 'Undo-AzKeyVaultCertificateRemoval'.
VERBOSE: Exporting cmdlet 'Update-AzKeyVaultCertificate'.
VERBOSE: Exporting cmdlet 'Get-AzKeyVault'.
VERBOSE: Exporting cmdlet 'Add-AzKeyVaultKey'.
VERBOSE: Exporting cmdlet 'Backup-AzKeyVaultKey'.
VERBOSE: Exporting cmdlet 'Get-AzKeyVaultKey'.
VERBOSE: Exporting cmdlet 'Remove-AzKeyVaultKey'.
VERBOSE: Exporting cmdlet 'Restore-AzKeyVaultKey'.
VERBOSE: Exporting cmdlet 'Undo-AzKeyVaultKeyRemoval'.
VERBOSE: Exporting cmdlet 'Update-AzKeyVaultKey'.
VERBOSE: Exporting cmdlet 'Remove-AzKeyVaultManagedHsm'.
VERBOSE: Exporting cmdlet 'Undo-AzKeyVaultManagedHsmRemoval'.
VERBOSE: Exporting cmdlet 'Add-AzKeyVaultManagedStorageAccount'.
VERBOSE: Exporting cmdlet 'Backup-AzKeyVaultManagedStorageAccount'.
VERBOSE: Exporting cmdlet 'Get-AzKeyVaultManagedStorageAccount'.
VERBOSE: Exporting cmdlet 'Get-AzKeyVaultManagedStorageSasDefinition'.
VERBOSE: Exporting cmdlet 'Remove-AzKeyVaultManagedStorageAccount'.
VERBOSE: Exporting cmdlet 'Remove-AzKeyVaultManagedStorageSasDefinition'.
VERBOSE: Exporting cmdlet 'Restore-AzKeyVaultManagedStorageAccount'.
VERBOSE: Exporting cmdlet 'Set-AzKeyVaultManagedStorageSasDefinition'.
VERBOSE: Exporting cmdlet 'Undo-AzKeyVaultManagedStorageAccountRemoval'.
VERBOSE: Exporting cmdlet 'Undo-AzKeyVaultManagedStorageSasDefinitionRemoval'.
VERBOSE: Exporting cmdlet 'Update-AzKeyVaultManagedStorageAccount'.
VERBOSE: Exporting cmdlet 'Update-AzKeyVaultManagedStorageAccountKey'.
VERBOSE: Exporting cmdlet 'New-AzKeyVault'.
VERBOSE: Exporting cmdlet 'Remove-AzKeyVault'.
VERBOSE: Exporting cmdlet 'Remove-AzKeyVaultAccessPolicy'.
VERBOSE: Exporting cmdlet 'Backup-AzKeyVaultSecret'.
VERBOSE: Exporting cmdlet 'Get-AzKeyVaultSecret'.
VERBOSE: Exporting cmdlet 'Remove-AzKeyVaultSecret'.
VERBOSE: Exporting cmdlet 'Restore-AzKeyVaultSecret'.
VERBOSE: Exporting cmdlet 'Set-AzKeyVaultSecret'.
VERBOSE: Exporting cmdlet 'Undo-AzKeyVaultSecretRemoval'.
VERBOSE: Exporting cmdlet 'Update-AzKeyVaultSecret'.
VERBOSE: Exporting cmdlet 'Set-AzKeyVaultAccessPolicy'.
VERBOSE: Exporting cmdlet 'Undo-AzKeyVaultRemoval'.
VERBOSE: Exporting cmdlet 'Update-AzKeyVault'.
VERBOSE: Exporting cmdlet 'Add-AzKeyVaultNetworkRule'.
VERBOSE: Exporting cmdlet 'New-AzKeyVaultNetworkRuleSetObject'.
VERBOSE: Exporting cmdlet 'Remove-AzKeyVaultNetworkRule'.
VERBOSE: Exporting cmdlet 'Update-AzKeyVaultNetworkRuleSet'.
VERBOSE: Exporting cmdlet 'Export-AzKeyVaultSecurityDomain'.
VERBOSE: Exporting cmdlet 'Import-AzKeyVaultSecurityDomain'.
VERBOSE: Exporting cmdlet 'New-AzKeyVaultCertificateAdministratorDetail'.
VERBOSE: Exporting cmdlet 'New-AzKeyVaultCertificateOrganizationDetail'.
VERBOSE: Exporting cmdlet 'Get-AzKeyVaultCertificatePolicy'.
VERBOSE: Exporting cmdlet 'Backup-AzKeyVault'.
VERBOSE: Exporting cmdlet 'Restore-AzKeyVault'.
VERBOSE: Exporting cmdlet 'Get-AzKeyVaultManagedHsm'.
VERBOSE: Exporting cmdlet 'New-AzKeyVaultManagedHsm'.
VERBOSE: Exporting cmdlet 'Update-AzKeyVaultManagedHsm'.
VERBOSE: Exporting cmdlet 'Get-AzKeyVaultRoleAssignment'.
VERBOSE: Exporting cmdlet 'Get-AzKeyVaultRoleDefinition'.
VERBOSE: Exporting cmdlet 'New-AzKeyVaultRoleDefinition'.
VERBOSE: Exporting cmdlet 'New-AzKeyVaultRoleAssignment'.
VERBOSE: Exporting cmdlet 'Remove-AzKeyVaultRoleAssignment'.
VERBOSE: Exporting cmdlet 'Remove-AzKeyVaultRoleDefinition'.
VERBOSE: Exporting cmdlet 'Get-AzKeyVaultSetting'.
VERBOSE: Exporting cmdlet 'Update-AzKeyVaultSetting'.
VERBOSE: Exporting cmdlet 'Get-AzKeyVaultRandomNumber'.
VERBOSE: Exporting cmdlet 'Invoke-AzKeyVaultKeyOperation'.
VERBOSE: Exporting cmdlet 'Get-AzKeyVaultKeyRotationPolicy'.
VERBOSE: Exporting cmdlet 'Set-AzKeyVaultKeyRotationPolicy'.
VERBOSE: Exporting cmdlet 'Invoke-AzKeyVaultKeyRotation'.
VERBOSE: Exporting alias 'Set-AzKeyVaultCertificateAttribute'.
VERBOSE: Exporting alias 'Set-AzKeyVaultKey'.
VERBOSE: Exporting alias 'Set-AzKeyVaultKeyAttribute'.
VERBOSE: Exporting alias 'Set-AzKeyVaultSecretAttribute'.
VERBOSE: Exporting alias 'Set-AzKeyVaultRoleDefinition'.
VERBOSE: Importing cmdlet 'Add-AzKeyVaultCertificate'.
VERBOSE: Importing cmdlet 'Add-AzKeyVaultCertificateContact'.
VERBOSE: Importing cmdlet 'Add-AzKeyVaultKey'.
VERBOSE: Importing cmdlet 'Add-AzKeyVaultManagedStorageAccount'.
VERBOSE: Importing cmdlet 'Add-AzKeyVaultNetworkRule'.
VERBOSE: Importing cmdlet 'Backup-AzKeyVault'.
VERBOSE: Importing cmdlet 'Backup-AzKeyVaultCertificate'.
VERBOSE: Importing cmdlet 'Backup-AzKeyVaultKey'.
VERBOSE: Importing cmdlet 'Backup-AzKeyVaultManagedStorageAccount'.
VERBOSE: Importing cmdlet 'Backup-AzKeyVaultSecret'.
VERBOSE: Importing cmdlet 'Export-AzKeyVaultSecurityDomain'.
VERBOSE: Importing cmdlet 'Get-AzKeyVault'.
VERBOSE: Importing cmdlet 'Get-AzKeyVaultCertificate'.
VERBOSE: Importing cmdlet 'Get-AzKeyVaultCertificateContact'.
VERBOSE: Importing cmdlet 'Get-AzKeyVaultCertificateIssuer'.
VERBOSE: Importing cmdlet 'Get-AzKeyVaultCertificateOperation'.
VERBOSE: Importing cmdlet 'Get-AzKeyVaultCertificatePolicy'.
VERBOSE: Importing cmdlet 'Get-AzKeyVaultKey'.
VERBOSE: Importing cmdlet 'Get-AzKeyVaultKeyRotationPolicy'.
VERBOSE: Importing cmdlet 'Get-AzKeyVaultManagedHsm'.
VERBOSE: Importing cmdlet 'Get-AzKeyVaultManagedStorageAccount'.
VERBOSE: Importing cmdlet 'Get-AzKeyVaultManagedStorageSasDefinition'.
VERBOSE: Importing cmdlet 'Get-AzKeyVaultRandomNumber'.
VERBOSE: Importing cmdlet 'Get-AzKeyVaultRoleAssignment'.
VERBOSE: Importing cmdlet 'Get-AzKeyVaultRoleDefinition'.
VERBOSE: Importing cmdlet 'Get-AzKeyVaultSecret'.
VERBOSE: Importing cmdlet 'Get-AzKeyVaultSetting'.
VERBOSE: Importing cmdlet 'Import-AzKeyVaultCertificate'.
VERBOSE: Importing cmdlet 'Import-AzKeyVaultSecurityDomain'.
VERBOSE: Importing cmdlet 'Invoke-AzKeyVaultKeyOperation'.
VERBOSE: Importing cmdlet 'Invoke-AzKeyVaultKeyRotation'.
VERBOSE: Importing cmdlet 'New-AzKeyVault'.
VERBOSE: Importing cmdlet 'New-AzKeyVaultCertificateAdministratorDetail'.
VERBOSE: Importing cmdlet 'New-AzKeyVaultCertificateOrganizationDetail'.
VERBOSE: Importing cmdlet 'New-AzKeyVaultCertificatePolicy'.
VERBOSE: Importing cmdlet 'New-AzKeyVaultManagedHsm'.
VERBOSE: Importing cmdlet 'New-AzKeyVaultNetworkRuleSetObject'.
VERBOSE: Importing cmdlet 'New-AzKeyVaultRoleAssignment'.
VERBOSE: Importing cmdlet 'New-AzKeyVaultRoleDefinition'.
VERBOSE: Importing cmdlet 'Remove-AzKeyVault'.
VERBOSE: Importing cmdlet 'Remove-AzKeyVaultAccessPolicy'.
VERBOSE: Importing cmdlet 'Remove-AzKeyVaultCertificate'.
VERBOSE: Importing cmdlet 'Remove-AzKeyVaultCertificateContact'.
VERBOSE: Importing cmdlet 'Remove-AzKeyVaultCertificateIssuer'.
VERBOSE: Importing cmdlet 'Remove-AzKeyVaultCertificateOperation'.
VERBOSE: Importing cmdlet 'Remove-AzKeyVaultKey'.
VERBOSE: Importing cmdlet 'Remove-AzKeyVaultManagedHsm'.
VERBOSE: Importing cmdlet 'Remove-AzKeyVaultManagedStorageAccount'.
VERBOSE: Importing cmdlet 'Remove-AzKeyVaultManagedStorageSasDefinition'.
VERBOSE: Importing cmdlet 'Remove-AzKeyVaultNetworkRule'.
VERBOSE: Importing cmdlet 'Remove-AzKeyVaultRoleAssignment'.
VERBOSE: Importing cmdlet 'Remove-AzKeyVaultRoleDefinition'.
VERBOSE: Importing cmdlet 'Remove-AzKeyVaultSecret'.
VERBOSE: Importing cmdlet 'Restore-AzKeyVault'.
VERBOSE: Importing cmdlet 'Restore-AzKeyVaultCertificate'.
VERBOSE: Importing cmdlet 'Restore-AzKeyVaultKey'.
VERBOSE: Importing cmdlet 'Restore-AzKeyVaultManagedStorageAccount'.
VERBOSE: Importing cmdlet 'Restore-AzKeyVaultSecret'.
VERBOSE: Importing cmdlet 'Set-AzKeyVaultAccessPolicy'.
VERBOSE: Importing cmdlet 'Set-AzKeyVaultCertificateIssuer'.
VERBOSE: Importing cmdlet 'Set-AzKeyVaultCertificatePolicy'.
VERBOSE: Importing cmdlet 'Set-AzKeyVaultKeyRotationPolicy'.
VERBOSE: Importing cmdlet 'Set-AzKeyVaultManagedStorageSasDefinition'.
VERBOSE: Importing cmdlet 'Set-AzKeyVaultSecret'.
VERBOSE: Importing cmdlet 'Stop-AzKeyVaultCertificateOperation'.
VERBOSE: Importing cmdlet 'Undo-AzKeyVaultCertificateRemoval'.
VERBOSE: Importing cmdlet 'Undo-AzKeyVaultKeyRemoval'.
VERBOSE: Importing cmdlet 'Undo-AzKeyVaultManagedHsmRemoval'.
VERBOSE: Importing cmdlet 'Undo-AzKeyVaultManagedStorageAccountRemoval'.
VERBOSE: Importing cmdlet 'Undo-AzKeyVaultManagedStorageSasDefinitionRemoval'.
VERBOSE: Importing cmdlet 'Undo-AzKeyVaultRemoval'.
VERBOSE: Importing cmdlet 'Undo-AzKeyVaultSecretRemoval'.
VERBOSE: Importing cmdlet 'Update-AzKeyVault'.
VERBOSE: Importing cmdlet 'Update-AzKeyVaultCertificate'.
VERBOSE: Importing cmdlet 'Update-AzKeyVaultKey'.
VERBOSE: Importing cmdlet 'Update-AzKeyVaultManagedHsm'.
VERBOSE: Importing cmdlet 'Update-AzKeyVaultManagedStorageAccount'.
VERBOSE: Importing cmdlet 'Update-AzKeyVaultManagedStorageAccountKey'.
VERBOSE: Importing cmdlet 'Update-AzKeyVaultNetworkRuleSet'.
VERBOSE: Importing cmdlet 'Update-AzKeyVaultSecret'.
VERBOSE: Importing cmdlet 'Update-AzKeyVaultSetting'.
VERBOSE: Importing function 'Add-AzKeyVaultManagedHsmRegion'.
VERBOSE: Importing function 'Get-AzKeyVaultManagedHsmRegion'.
VERBOSE: Importing function 'Remove-AzKeyVaultManagedHsmRegion'.
VERBOSE: Importing function 'Test-AzKeyVaultManagedHsmNameAvailability'.
VERBOSE: Importing function 'Test-AzKeyVaultNameAvailability'.
VERBOSE: Importing alias 'Set-AzKeyVaultCertificateAttribute'.
VERBOSE: Importing alias 'Set-AzKeyVaultKey'.
VERBOSE: Importing alias 'Set-AzKeyVaultKeyAttribute'.
VERBOSE: Importing alias 'Set-AzKeyVaultRoleDefinition'.
VERBOSE: Importing alias 'Set-AzKeyVaultSecretAttribute'.
The extension logfile:
9/20/2023 2:37:56 PM [NORMAL] - Visual Studio Code: v1.80.1 64-bit on Windows 64-bit
9/20/2023 2:37:56 PM [NORMAL] - PowerShell process started with PID: 4816
9/20/2023 2:37:56 PM [NORMAL] - PowerShell Extension: v2023.9.2
9/20/2023 2:37:56 PM [NORMAL] - Starting 'PowerShell (x64)' at: C:\Program Files\PowerShell\7\pwsh.exe
9/20/2023 2:38:02 PM [NORMAL] - Started PowerShell v7.3.7.
9/20/2023 2:38:03 PM [NORMAL] - PowerShell is up-to-date.
Any suggestions on how to proceed?
> $PSVersionTable
Name Value
---- -----
PSVersion 7.3.7
PSEdition Core
GitCommitId 7.3.7
OS Microsoft Windows 10.0.19045
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Alright. So this morning, the day after reporting the issue in this thread, the problem does not occur any longer. But unlike @wsmelton, I did not update anything. The only thing happening in between was a reboot 🙄
Ah, well... $Whatever | Float-YourGoat
Today, the same problem is back again, unfortunatelly:
Connect-AzAccount:
Line |
8 | Connect-AzAccount
| ~~~~~~~~~~~~~~~~~
| The 'Connect-AzAccount' command was found in the module 'Az.Accounts', but the module could not be loaded due to the following error: [Assembly with same name is already loaded]
For more information, run 'Import-Module Az.Accounts'.
Only thing that happened in between my posts is a shutdown/startup of the system. I don't receive this error with any other session of pwsh in VS Code or Windows Terminal - only with the PowerShell Extension in VS Code.
Have any of you had a chance to test with the latest pre-release, v2023.9.3-preview? It included a major OmniSharp update (which updated Newtonsoft.Json that was at least one of the conflicting problems).
I'm using the pre-release v2023.9.4
and beginning to see this again.
@andyleejordan happy to jump on a Teams call with the team if needed.
This is kind of just a known issue with the Az
suite of modules; they do not implement assembly isolation correctly across the board and so run into assembly conflicts in various configurations. These issues show up everywhere, but more often with the Extension Terminal because we have more dependencies loaded underneath to support the LSP server (and the way the assembly isolation works requires both parties to be doing it correctly, 100% of the time, we gave a whole talk on this at PSConfEU this summer). I would highly suggest just hiding the Extension Terminal and using normal pwsh
instances in the VS Code terminal pane (click the +
button and you can also set powershell.integratedConsole.startInBackground
to hide the Extension Terminal at startup and just let it server its primary purpose in the background, which is powering the extension's features by hosting an LSP server).
I'm seeing the same issue with Az.Accounts. And it's really annoying when that module is the best way to get authorization tokens to work with any of the Azure related Rest API's. Should we also report it as a bug for the Az module?
I'm seeing the same issue with Az.Accounts. And it's really annoying when that module is the best way to get authorization tokens to work with any of the Azure related Rest API's. Should we also report it as a bug for the Az module?
Same here, pain in the butt. No current workaround.
Should we also report it as a bug for the Az module?
Yes please.
Found a workaround. If I do a forced update of both the Az.Storage and Az.Accounts modules, I’m back to working.
...I would highly suggest just hiding the Extension Terminal and using normal
pwsh
instances in the VS Code terminal pane (click the+
button and you can also setpowershell.integratedConsole.startInBackground
to hide the Extension Terminal at startup and just let it server its primary purpose in the background, which is powering the extension's features by hosting an LSP server).
I'm seeing this issue with MS Graph SDK. Is there an idiot's guide to implementing @andyleejordan recommendation? I found that when I want to Debug code the PIC is used regardless of having the powershell.integratedConsole.startInBackground
to hide.
Found a workaround. If I do a forced update of both the Az.Storage and Az.Accounts modules, I’m back to working.
I am trying to do a remove and import of these 2 but I still get the issue. Can you post your workaround, maybe i am missing something
@PaulBendall the issue has nothing to do with vscode specifically, basically what happens is that the Az modules have some common .NET libraries, and if one loads a lower version before another one that requires a higher version, that module will run into an error. It's even worse in PowerShell 5.1 vs 7 because assembly binding redirects aren't a thing.
It appears to happen more in vscode because the engine that makes vscode work, despite hiding some things properly, still has some common DLLs it has to load that might conflict
The best thing to do is to clean out all your Az modules, and then install specifically the ones you need at the same time with Install-PSResource
to ensure you get the correct interdependencies, and then update all those modules together.
Also, you may have other modules loaded that use the same DLLs as Az (such as Azure.Identity). Ideally you load those in your system after Az and on Powershell 7+ so that binding redirects can work. Also keep your vscode extension up to date.
That's the best advice I can offer.