2

I am developing commandlets in C#. The commandlets use these Azure packages.

<PackageReference Include="Azure.Messaging.ServiceBus" Version="7.1.0" />
<PackageReference Include="Azure.Search.Documents" Version="11.3.0" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.8.0" />
<PackageReference Include="Microsoft.Azure.Cosmos.Table" Version="1.0.8" />
<PackageReference Include="Microsoft.Azure.Management.Fluent" Version="1.37.0" />
<PackageReference Include="Microsoft.Azure.Management.ResourceManager.Fluent" Version="1.37.0" />
<PackageReference Include="Microsoft.Azure.ServiceBus" Version="5.1.1" />
<PackageReference Include="Microsoft.Azure.Services.AppAuthentication" Version="1.6.1" />

We build the commandlets into an assembly (DLL) and then import that assembly as a module.

Import-Module path/to/our/assembly.dll;

This usually works terrifically. A problem occurs, though, when we combine our commandlets with those from Az.Accounts and/or Az.Storage. For instance, the following will throw an error:

New-AzStorageContext -ConnectionString $StorageAccountConnectionString `
| Get-AzStorageContainer `
| Get-AzStorageBlob;

Invoke-OurCustomCommandlet

When we invoke our custom commandlet, we see the following error:

Could not load file or assembly 'Azure.Core, Version=1.15.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8'. Could not find or load a specific file. (0x80131621)

How can we resolve this, so that our custom commandlets can interact with the Az modules? Our commandlets work fine when we have not run those Az module commandlets first.

Shaun Luttin
  • 133,272
  • 81
  • 405
  • 467
  • 2
    You're experiencing dependency conflicts because the AZ cmdlets are using different versions of the same libraries. Here is a recent answer about [resolving dependency conflicts](https://stackoverflow.com/a/69403558/9164015). The link to DevBlogs at the bottom might be most useful. – Ash Oct 06 '21 at 08:12

0 Answers0