Azure / Azure/azure-powershell

[Feature]: Az.KeyVault: Use BouncyCastle with an Assembly Load Context

Open
#19,375 2 comments 2 reactions 0 assignees View on GitHub
act-identity-squad customer-reported feature-request KeyVault
Dominant language
C#
Stars
4.8k
Forks
4.3k
Avg merge
2d 17h
Merged PRs (30d)
51

Description

### Description of the new feature

Az.KeyVault has a tiny dependency on the BouncyCastle library which is commonly used in other modules relating to cryptography and PKI. Attempting to import this module at the same time as other modules with the same dependency causes assembly load errors on PS 6+ if the version of the library doesn't match. It doesn't seem to matter which module is imported first. This problem and a number of workarounds are described here:

https://devblogs.microsoft.com/powershell/resolving-powershell-module-assembly-dependency-conflicts

One of the suggested "robust" workarounds involves moving the dependent library into a separate engine module using Assembly Load Contexts to isolate the library from PowerShell's default ALC and prevent the conflict with other modules. @rjmholt has an example of this technique in this repo.

https://github.com/rjmholt/ModuleDependencyIsolationExample

Using ALCs seems to be a solution only for compiled modules like Az.KeyVault. Whereas my own conflicting module is a script-module and doesn't have a good way to isolate the BouncyCastle dependency. But I'm also open to suggestions on workarounds I could use in my own module.

### Proposed implementation details (optional)

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.