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:
@{
'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'
}
Import-Module Az.Accounts
Import-Module PnP.PowerShell
Connect-PnPOnline -Url 'https://contoso.sharepoint.com' -ClientId '<id>' -ClientSecret '<secret>'
# -> 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
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
Summary
Az.Accounts5.5.1 ships a newerMicrosoft.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 bundleMicrosoft.Extensions.Http8.0.0.0 (e.g.PnP.PowerShell3.2.0 /PnP.Framework), and the resulting binding mismatch throws aSystem.MissingMethodException.Downgrading to
Az.Accounts5.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
What changed between 5.5.0 and 5.5.1
Controlled test — only the
Az.Accountsversion changed, same worker (PS 7.4.13 / .NET 8), samePnP.PowerShell3.2.0:Az.AccountsMicrosoft.Extensions.OptionsloadedMissingMethodExceptionMicrosoft.Extensions.Http8.0.0.0 (from PnP.Framework) calls theAddOptions(IServiceCollection)overload thatMicrosoft.Extensions.Options10.0.0.0 no longer exposes.Reproduction
requirements.psd1in a PowerShell 7.4 Functions app:Note: reproduced only inside the Functions worker; a bare
pwsh7.4.13 with the same modules does not crash (see #1144). But since the trigger is theMicrosoft.Extensions.Optionsversion bump in 5.5.1, raising here as well.Workaround
Ask
Microsoft.Extensions.Optionsbump to 10.0.0.0 inAz.Accounts5.5.1 intentional, and is it expected to coexist with modules bundlingMicrosoft.Extensions.Http8.0.0.0?Az.Accounts5.5.x withPnP.PowerShellin the PS 7.4 worker?Environment
Az.Accounts5.5.1