question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Az and AzureStack (Az) modules do not load assemblies when used with PartnerCenter modules in PS7 - Assembly with same name is already loaded

See original GitHub issue

Steps to reproduce

PS /> Get-Module -ListAvailable -Name Az.*,Azs.*,Partner*


    Directory: /root/.local/share/powershell/Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     2.0.1      preview    Az.Accounts                         Core,Desk {Disable-AzDataCollection, Disable-AzCo…
Script     1.8.1                 Az.Accounts                         Core,Desk {Disable-AzDataCollection, Disable-AzCo…
Script     0.1.0      preview    Az.BootStrapper                     Core,Desk {Update-AzProfile, Uninstall-AzProfile,…
Script     2.0.0                 Az.KeyVault                         Core,Desk {Add-AzKeyVaultCertificate, Update-AzKe…
Script     0.10.0     preview    Az.Resources                        Core,Desk {Get-AzProviderOperation, Remove-AzRole…
Script     0.9.0      preview    Azs.Backup.Admin                    Core,Desk {Get-AzsBackup, Get-AzsBackupConfigurat…
Script     0.9.0      preview    Azs.Commerce.Admin                  Core,Desk Get-AzsSubscriberUsage
Script     0.9.0      preview    Azs.Compute.Admin                   Core,Desk {Add-AzsPlatformImage, Add-AzsVMExtensi…
Script     0.9.0      preview    Azs.Deployment.Admin                Core,Desk {Invoke-AzsProductExecuteRunnerAction, …
Script     0.9.0      preview    Azs.Fabric.Admin                    Core,Desk {Add-AzsScaleUnitNode, Disable-AzsScale…
Script     0.9.0      preview    Azs.Gallery.Admin                   Core,Desk {Add-AzsGalleryItem, Get-AzsGalleryItem…
Script     0.9.0      preview    Azs.Network.Admin                   Core,Desk {Get-AzsLoadBalancer, Get-AzsNetworkAdm…
Script     0.9.0      preview    Azs.Storage.Admin                   Core,Desk {Get-AzsStorageAccount, Get-AzsStorageA…
Script     0.9.0      preview    Azs.Subscriptions                   Core,Desk {Get-AzsDelegatedProviderOffer, Get-Azs…
Script     0.9.0      preview    Azs.Subscriptions.Admin             Core,Desk {Add-AzsPlanToOffer, Get-AzsAcquiredPla…
Script     0.9.0      preview    Azs.Update.Admin                    Core,Desk {Get-AzsUpdate, Get-AzsUpdateLocation, …

    Directory: /usr/local/share/powershell/Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     3.0.9                 PartnerCenter                       Core,Desk {Add-PartnerCustomerCartLineItem, Add-P…

PS /> cat /etc/issue
Ubuntu 18.04.4 LTS \n \l

PS /> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.0.1
PSEdition                      Core
GitCommitId                    7.0.1
OS                             Linux 4.9.125-linuxkit #1 SMP Fri Sep 7 08:20:28 UTC 2018
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

PS /> Import-Module AzureStack
Import-Module: The required module 'Azs.AzureBridge.Admin' is not loaded. Load the module or remove the module from 'RequiredModules' in the file '/root/.local/share/powershell/Modules/AzureStack/2.0.0/AzureStack.psd1'.
PS /> Import-Module /root/.local/share/powershell/Modules/Azs.Azurebridge.Admin/0.9.0/Azs.AzureBridge.Admin.psd1 -verbose
VERBOSE: Loading module from path '/root/.local/share/powershell/Modules/Azs.Azurebridge.Admin/0.9.0/Azs.AzureBridge.Admin.psd1'.
VERBOSE: Loading 'Assembly' from path '/root/.local/share/powershell/Modules/Azs.Azurebridge.Admin/0.9.0/bin/Azs.AzureBridge.Admin.private.dll'.
VERBOSE: Loading 'Executable' from path '/root/.local/share/powershell/Modules/Azs.Azurebridge.Admin/0.9.0/bin/Azs.AzureBridge.Admin.private.dll'.
VERBOSE: Loading 'FormatsToProcess' from path '/root/.local/share/powershell/Modules/Azs.Azurebridge.Admin/0.9.0/Azs.AzureBridge.Admin.format.ps1xml'.
VERBOSE: Populating RepositorySourceLocation property for module Azs.AzureBridge.Admin.
VERBOSE: Loading module from path '/root/.local/share/powershell/Modules/Azs.Azurebridge.Admin/0.9.0/Azs.AzureBridge.Admin.psm1'.
VERBOSE: Importing function 'Get-AzsAzureBridgeActivation'.
VERBOSE: Importing function 'Get-AzsAzureBridgeDownloadedProduct'.
VERBOSE: Importing function 'Get-AzsAzureBridgeProduct'.
VERBOSE: Importing function 'Invoke-AzsAzureBridgeProductDownload'.
VERBOSE: Importing function 'Remove-AzsAzureBridgeDownloadedProduct'.
PS /> Import-Module /root/.local/share/powershell/Modules/Azs.Infrastructureinsights.Admin/0.9.0/Azs.InfrastructureInsights.Admin.psd1 -Verbose
VERBOSE: Loading module from path '/root/.local/share/powershell/Modules/Azs.Infrastructureinsights.Admin/0.9.0/Azs.InfrastructureInsights.Admin.psd1'.
VERBOSE: Loading 'Assembly' from path '/root/.local/share/powershell/Modules/Azs.Infrastructureinsights.Admin/0.9.0/bin/Azs.InfrastructureInsights.Admin.private.dll'.
VERBOSE: Loading 'Executable' from path '/root/.local/share/powershell/Modules/Azs.Infrastructureinsights.Admin/0.9.0/bin/Azs.InfrastructureInsights.Admin.private.dll'.
VERBOSE: Loading 'FormatsToProcess' from path '/root/.local/share/powershell/Modules/Azs.Infrastructureinsights.Admin/0.9.0/Azs.InfrastructureInsights.Admin.format.ps1xml'.
VERBOSE: Populating RepositorySourceLocation property for module Azs.InfrastructureInsights.Admin.
VERBOSE: Loading module from path '/root/.local/share/powershell/Modules/Azs.Infrastructureinsights.Admin/0.9.0/Azs.InfrastructureInsights.Admin.psm1'.
VERBOSE: Importing function 'Close-AzsAlert'.
VERBOSE: Importing function 'Get-AzsAlert'.
VERBOSE: Importing function 'Get-AzsRegionHealth'.
VERBOSE: Importing function 'Get-AzsRegistrationHealth'.
VERBOSE: Importing function 'Get-AzsRPHealth'.
VERBOSE: Importing function 'Repair-AzsAlert'.
PS /> Import-Module /root/.local/share/powershell/Modules/Azs.Keyvault.Admin/0.9.0/Azs.KeyVault.Admin.psd1 -verbose
VERBOSE: Loading module from path '/root/.local/share/powershell/Modules/Azs.Keyvault.Admin/0.9.0/Azs.KeyVault.Admin.psd1'.
VERBOSE: Loading 'Assembly' from path '/root/.local/share/powershell/Modules/Azs.Keyvault.Admin/0.9.0/bin/Azs.KeyVault.Admin.private.dll'.
VERBOSE: Loading 'Executable' from path '/root/.local/share/powershell/Modules/Azs.Keyvault.Admin/0.9.0/bin/Azs.KeyVault.Admin.private.dll'.
VERBOSE: Loading 'FormatsToProcess' from path '/root/.local/share/powershell/Modules/Azs.Keyvault.Admin/0.9.0/Azs.KeyVault.Admin.format.ps1xml'.
VERBOSE: Populating RepositorySourceLocation property for module Azs.KeyVault.Admin.
VERBOSE: Loading module from path '/root/.local/share/powershell/Modules/Azs.Keyvault.Admin/0.9.0/Azs.KeyVault.Admin.psm1'.
VERBOSE: Importing function 'Get-AzsKeyvaultQuota'.
PS />
PS /> Import-Module AzureStack
WARNING: Preview version of AzureStack module is loaded, Future versions may have breaking changes
PS /> Import-Module PartnerCenter
Import-Module: Assembly with same name is already loaded
PS /> Get-Module

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     2.0.1      preview    Az.Accounts                         {Add-AzEnvironment, Clear-AzContext, Clear-AzDefa…
Script     0.10.0     preview    Az.Resources                        {Add-AzADGroupMember, Export-AzResourceGroup, Get…
Script     0.9.0      preview    Azs.AzureBridge.Admin               {Get-AzsAzureBridgeActivation, Get-AzsAzureBridge…
Script     0.9.0      preview    Azs.Backup.Admin                    {Get-AzsBackup, Get-AzsBackupConfiguration, Resto…
Script     0.9.0      preview    Azs.Commerce.Admin                  Get-AzsSubscriberUsage
Script     0.9.0      preview    Azs.Compute.Admin                   {Add-AzsPlatformImage, Add-AzsVMExtension, Get-Az…
Script     0.9.0      preview    Azs.Deployment.Admin                {Get-AzsActionPlan, Get-AzsActionPlanAttempt, Get…
Script     0.9.0      preview    Azs.Fabric.Admin                    {Add-AzsScaleUnitNode, Disable-AzsScaleUnitNode, …
Script     0.9.0      preview    Azs.Gallery.Admin                   {Add-AzsGalleryItem, Get-AzsGalleryItem, Remove-A…
Script     0.9.0      preview    Azs.InfrastructureInsights.Admin    {Close-AzsAlert, Get-AzsAlert, Get-AzsRegionHealt…
Script     0.9.0      preview    Azs.KeyVault.Admin                  Get-AzsKeyvaultQuota
Script     0.9.0      preview    Azs.Network.Admin                   {Get-AzsLoadBalancer, Get-AzsNetworkAdminOverview…
Script     0.9.0      preview    Azs.Storage.Admin                   {Get-AzsStorageAccount, Get-AzsStorageAcquisition…
Script     0.9.0      preview    Azs.Subscriptions                   {Get-AzsDelegatedProviderOffer, Get-AzsOffer, Get…
Script     0.9.0      preview    Azs.Subscriptions.Admin             {Add-AzsPlanToOffer, Get-AzsAcquiredPlan, Get-Azs…
Script     0.9.0      preview    Azs.Update.Admin                    {Get-AzsUpdate, Get-AzsUpdateLocation, Get-AzsUpd…
Script     2.0.0      preview    AzureStack
Manifest   7.0.0.0               Microsoft.PowerShell.Management     {Add-Content, Clear-Content, Clear-Item, Clear-It…
Manifest   7.0.0.0               Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Ob…
Script     2.0.0                 PSReadLine                          {Get-PSReadLineKeyHandler, Get-PSReadLineOption, …

PS />

Expected behavior

Modules should work side by side.

Actual behavior

Error message

Import-Module: Assembly with same name is already loaded

Environment

Tested on: Ubuntu18 CentOS7 WinServerCore2019

PS7.0.x PS7.1.x (beta) PowerShellGet 2.x.x PowerShellGet 3.0 (beta)

This basically defeats the purpose of Az modules because you cannot use them in PS Core.

Note: It all works fine in PS5.1

See https://github.com/microsoft/Partner-Center-PowerShell/issues/261 for additional info.

@isaiahwilliams Can we please look into this? I need this to work so I can switch to Linux containers. Please help!

Bonus: Ignore the fact that AzureStack module does not load properly in Linux - it loads fine on Windows… and you can see a workaround for Linux above anyway.

To reiterate as you can see below - loading AzureStack and PartnerCenter does not work whichever way you try. You can try AzureStack then PartnerCenter or vice versa and it is still broken.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
cblackukcommented, Jun 4, 2020

Yeah these will work:

Script     1.8.1                 az.accounts                         {Add-AzEnvironment, Clear-AzContext, Clear-AzDefa…

Script     2.1.0                 az.resources         

Problem is with the ones that AzureStack is using… Thanks though 😃 @slavizh

Script     2.0.1      Az.Accounts                         {Add-AzEnvironment, Clear-AzContext, Clear-AzDefault, Conn...
Script     0.10.0     Az.Resources    
1reaction
slavizhcommented, Jun 4, 2020

I am able to import them but I use only the Az modules and the Partner Center module. I am also using the GA version rather the previews. Here is my information if it helps for this case in some way.

PS C:\Users\stas> import-module az.accounts
PS C:\Users\stas> import-module az.resources
PS C:\Users\stas> import-module partnercenter
PS C:\Users\stas> Get-PartnerCustomer
Get-PartnerCustomer: Run Connect-PartnerCenter to login.
PS C:\Users\stas> Connect-PartnerCenter
WARNING: Attempting to launch a browser for authorization code login.
WARNING: We have launched a browser for you to login. For the old experience with device code flow, please run 'Connect-PartnerCenter -UseDeviceAuthentication'.
PS C:\Users\stas> Get-Module

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     1.8.1                 az.accounts                         {Add-AzEnvironment, Clear-AzContext, Clear-AzDefa…
Script     2.1.0                 az.resources                        {Add-AzADGroupMember, Export-AzResourceGroup, Get…
Manifest   7.0.0.0               Microsoft.PowerShell.Management     {Add-Content, Clear-Content, Clear-Item, Clear-It…
Manifest   7.0.0.0               Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Ob…
Script     3.0.9                 partnercenter                       {Add-PartnerCustomerCartLineItem, Add-PartnerCust…
Script     2.0.0                 PSReadLine                          {Get-PSReadLineKeyHandler, Get-PSReadLineOption, …

PS C:\Users\stas>
PS C:\Users\stas>


Read more comments on GitHub >

github_iconTop Results From Across the Web

Azure Automation PowerShell Error "Assembly with same ...
The error message indicates that the Az.Accounts module is already loaded, but it can't be loaded again. This error occurs when you try...
Read more >
Azure Automation PowerShell Error "Assembly with same ...
The 'Connect-AzAccount' command was found in the module 'Az.Accounts', but the module could not be loaded due to the following error: | [ ......
Read more >
How to fix "Assembly with same name is already loaded ...
Hi, I am deploying a few Azure resources using az PowerShell and MgGraph PowerShell modules, using deployment script in an ARM Template, ...
Read more >
Resolving PowerShell module assembly dependency ...
PowerShell always loads assemblies into the same context. This presents issues when a module's dependencies conflict with already-loaded ...
Read more >
Install PowerShell Az module for Azure Stack Hub
This article explains how to install the Azure PowerShell Az and compatible Azure Stack Hub administrator modules using PowerShellGet. The Az ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found