Azure / Azure/azure-powershell

Az.Accounts 5.5.1 bumps Microsoft.Extensions.Options to 10.0.0.0, breaking PnP.PowerShell in the PS 7.4 Functions worker (MissingMethodException)

Open
#29,833 1 comment 0 reactions 0 assignees View on GitHub
act-identity-squad
Dominant language
C#
Stars
4.8k
Forks
4.3k
Avg merge
2d 17h
Merged PRs (30d)
51

Description

## Summary

`Az.Accounts` **5.5.1** ships a newer `Microsoft.Extensions.Options` (assembly version **10.0.0.0**) than **5.5.0** (which shipped **8.0.0.0**). In the Azure Functions PowerShell 7.4 worker, this newer assembly gets co-loaded with modules that bundle `Microsoft.Extensions.Http` 8.0.0.0 (e.g. `PnP.PowerShell` 3.2.0 / `PnP.Framework`), and the resulting binding mismatch throws a `System.MissingMethodException`.

Downgrading to `Az.Accounts` **5.5.0** resolves it. Reported by multiple customers.

Companion worker-side issue: **Azure/azure-functions-powershell-worker#1144** (full worker analysis, repro, and worker-isolation question).

## Exception

```
System.MissingMethodException: Method not found:
'Microsoft.Extensions.DependencyInjection.IServiceCollection
Microsoft.Extensions.DependencyInjection.OptionsServiceCollectionExtensions.AddOptions(
Microsoft.Extensions.DependencyInjection.IServiceCollection)'.
at Microsoft.Extensions.DependencyInjection.HttpClientFactoryServiceCollectionExtensions.AddHttpClient(IServiceCollection services)
at PnP.Framework.Http.PnPHttpClient.AddHttpClients(IServiceCollection collection, String UserAgent)
...
at PnP.PowerShell.Commands.Base.ConnectOnline.ProcessRecord()
```

## What changed between 5.5.0 and 5.5.1

Controlled test — only the `Az.Accounts` version changed, same worker (PS 7.4.13 / .NET 8), same `PnP.PowerShell` 3.2.0:

| `Az.Accounts` | `Microsoft.Extensions.Options` loaded | Result |
|---|---|---|
| 5.5.1 | **10.0.0.0** | ❌ `MissingMethodException` |
| 5.5.0 | **8.0.0.0** | ✅ works |

`Microsoft.Extensions.Http` 8.0.0.0 (from PnP.Framework) calls the `AddOptions(IServiceCollection)` overload that `Microsoft.Extensions.Options` 10.0.0.0 no longer exposes.

## Reproduction

`requirements.psd1` in a PowerShell 7.4 Functions app:

```powershell
@{
'Az.Accounts' = '5.5.1'
'Az.Resources' = '10.0.0'
'Az.Storage' = '9.7.0'
'PnP.PowerShell' = '3.2.0'
'Az.KeyVault' = '6.5.0'
}
```

```powershell
Import-Module Az.Accounts
Import-Module PnP.PowerShell
Connect-PnPOnline -Url 'https://contoso.sharepoint.com' -ClientId '' -ClientSecret ''
# -> System.MissingMethodException
```

Note: reproduced only inside the Functions worker; a bare `pwsh` 7.4.13 with the same modules does not crash (see #1144). But since the trigger is the `Microsoft.Extensions.Options` version bump in 5.5.1, raising here as well.

## Workaround

```powershell
'Az.Accounts' = '5.5.0'
```

## Ask

- Was the `Microsoft.Extensions.Options` bump to 10.0.0.0 in `Az.Accounts` 5.5.1 intentional, and is it expected to coexist with modules bundling `Microsoft.Extensions.Http` 8.0.0.0?
- Any guidance for customers combining `Az.Accounts` 5.5.x with `PnP.PowerShell` in the PS 7.4 worker?

## Environment

- `Az.Accounts` 5.5.1
- Azure Functions PowerShell worker 7.4.13 (.NET 8), Core Tools 4.12.1
- Managed dependencies enabled

Contributor guide

Open the contributing guide

Research direction

Start with the requirements.psd1 reproduction in a PowerShell 7.4 Functions worker, comparing Az.Accounts 5.5.0 and 5.5.1 while importing PnP.PowerShell and running Connect-PnPOnline. Read the linked Azure Functions PowerShell worker issue #1144 and inspect how the Microsoft.Extensions.Options and Microsoft.Extensions.Http assemblies are packaged and loaded. Done means the supported module combination no longer throws MissingMethodException, or its compatibility guidance is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, powershell
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.