azure-powershell icon indicating copy to clipboard operation
azure-powershell copied to clipboard

[Eng]: Import-module CosmosDB throwing error "Assembly with same name is already loaded" in Azure Powershell

Open vuvasira opened this issue 3 years ago • 3 comments

Description

Hello,

The customers pipeline has multiple tasks :

Initial task loads the CosmosDB using the "Install-Module -Name 'CosmosDB' -MinimumVersion '4.5.0' -Force"

Another task in the same job Imports a psd1 module, with CosmosDb as required module as follows :

    RequiredModules      = @(         @{ ModuleName = 'CosmosDB'; ModuleVersion = '4.5.0' }     )

the above pipeline is working well with the Azure Powershell 8.2.0.

With the latest version ( 8.3.0 ) the second task is throwing the following error: "Assembly with same name is already loaded".

The current work around is to use the 8.2.0 version.

vuvasira avatar Sep 08 '22 11:09 vuvasira

@vuvasira , could you explain further? CosmosDB doesn't belong to Azure PowerShell module. Please provide one script example to reproduce the issue.

dingmeng-xue avatar Sep 11 '22 12:09 dingmeng-xue

Hi, we're sending this friendly reminder because we haven't heard back from you in a while. We need more information about this issue to help address it. Please be sure to give us your input within the next 7 days. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!

ghost avatar Sep 18 '22 14:09 ghost

Following are the simple script to re-create the issue :

Pipeline :

pool:
  name: Azure Pipelines
steps:
- task: AzurePowerShell@5
  displayName: 'Load ComosDB Module'
  inputs:
    azureSubscription: 'serviceconnection'
    ScriptType: InlineScript
    Inline: 'Install-Module -Name ''CosmosDB'' -MinimumVersion ''4.5.0'' -Force'
    azurePowerShellVersion: LatestVersion

- task: AzurePowerShell@5
  displayName: 'Load Custom Module'
  inputs:
    azureSubscription: 'serviceconnection'
    ScriptType: InlineScript
    Inline: 'Import-Module -Name  ./src/modules/foo.psd1 -Verbose -Force'
    azurePowerShellVersion: LatestVersion

foo.psd1 file content :

@{

    ModuleVersion        = '0.0.1'
    CompatiblePSEditions = @('Core')
    GUID                 = 'f0a61ff8-3bc6-45c0-beaa-5e587b01fc78'
    Author               = 'Vudaya Vasiraju'
    CompanyName          = 'Foo'
    Copyright            = '(c) Foo. All rights reserved.'
    Description          = 'A module to test the az powershell bug'
    RequiredModules      = @(
        @{ ModuleName = 'CosmosDB'; ModuleVersion = '4.5.0' }
    )
    CmdletsToExport      = @()
    VariablesToExport    = '*'
    AliasesToExport      = @()
    PrivateData          = @{
        PSData = @{
        }
    } 
}

ghost avatar Sep 20 '22 00:09 ghost