skip to Main Content

I am using let’s encrypt certificate and azure key vault to automate renewal process using this repo: https://github.com/brent-robinson/posh-acme-azure-example

I have installed the module Az.KeyVault using yaml on azure devops pipeline:

# Install the Az PowerShell modules our script will need
- task: PowerShell@2
  displayName: Install PowerShell Modules (Az.Accounts, Az.KeyVault, Az.Resources, Posh-ACME)
  inputs:
    targetType: 'inline'
    script: 'Install-Module Az.Accounts, Az.KeyVault, Az.Resources, Posh-ACME -Force'
    errorActionPreference: 'stop'
    failOnStderr: true
    pwsh: true

But, when I run the script, getting the below error:

The 'Get-AzKeyVaultCertificate' command was found in the
     | module 'Az.KeyVault', but the module could not be loaded. For
     | more information, run 'Import-Module Az.KeyVault'.

When I try to add the import module (Import-Module -Name Az.KeyVault -Force) it’s giving the below error:

Assembly with the same name is already loaded

2

Answers


  1. Chosen as BEST ANSWER

    There is an issue with the latest version of Posh-ACME module (4.15.0). Install version 4.14.0 to resolve this.

    Install-Module -Name Posh-ACME -RequiredVersion 4.14.0 -Force
    

    Ref: https://github.com/brent-robinson/posh-acme-azure-example/issues/15#issuecomment-1241850416


  2. When you try to install the module in CI/CD pipeline you can specify the user so that it won’t conflict with other.

    #install Az PowerShell Modules with Specific User
    - task: PowerShell@2
      displayName: Install PowerShell Modules (Az.Accounts, Az.KeyVault, Az.Resources, Posh-ACME)
      inputs:
        targetType: 'inline'
        script: 'Install-Module Az.Accounts, Az.KeyVault, Az.Resources, Posh-ACME -Force CurrentUser' 
    

    The ‘Get-AzKeyVaultCertificate’ command was found in the
    | module ‘Az.KeyVault’, but the module could not be loaded. For
    | more information, run ‘Import-Module Az.KeyVault’.

    Assembly with the same name is already loaded

    The error messages show that Az keyVault was already installed but not able to load in a pipeline to run task. You can specify the user(Current user or all user) to install the required module to specific user and import the required module.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search