-
Notifications
You must be signed in to change notification settings - Fork 488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to load Az modules - Assembly with same name is already loaded #4727
Comments
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 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 |
So I cannot replicate this on Windows (Windows 10, VS Code Insiders, PowerShell 7.2, and |
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:
and believe there is a PSSA rule that can cause modules to be imported when analyzing the file. |
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:
And I misread that earlier. |
@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 |
@andyleejordan happy to jump on a Teams call with the team if needed. |
This is kind of just a known issue with the |
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. |
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'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 |
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 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. |
I made an issue in both the Azure PowerShell (
Could someone more knowledgeable than me about "proper assembly isolation" chime in in respective issues on how they should proceed to fix this? Is there a best practice reference guide? Or a reference module that does this right? Edit: Other modules:
Edit 2: Created PowerShell discussion about this topic: |
It's called an Assembly Load Context, and I believe Az already has it partially implemented but they use it to hide only one assembly which doesn't really do the trick :). Also this would be for PS7+ only, wouldn't work for PS5.1 https://learn.microsoft.com/en-us/dotnet/api/system.runtime.loader.assemblyloadcontext?view=net-8.0 |
It is very strange what Az does with their ALC. Some modules use it to hide a one (or a few) assemblies, some don't use it all. None of them use it correctly. Granted, "correct" is hard to get right with ALC and it's a ridiculous ask of module others, but is unfortunately just how .NET apps work. |
As Microsoft seems to be focusing on security lately for many projects: Can ALC be an argument for better security? |
Not a solution, but a workaround that may help some of you while we wait for a fix: |
@matthiashaldimann that's a pretty good workaround as the temp console doesn't load PSES, so it won't have the same assembly conflicts. |
Prerequisites
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
Visual Studio Code Version
Extension Version
Steps to Reproduce
Get-Module Az*
Import-Module Az.Accounts
Import-Module: Assembly with same name is already loaded
Visuals
VSCode-PowerShell-Az.mp4
Logs
ext_logs.zip
The text was updated successfully, but these errors were encountered: