Repository navigation
Az.Resources 10.x.x is incompatible with Windows Powershell 5.1 #30201
Copy link
Copy link
Closed
Labels
ARMact-identity-squadbugThis issue requires a change to an existing behavior in the product in order to be resolved.This issue requires a change to an existing behavior in the product in order to be resolved.customer-reported
Description
Description
When removing a shared dashboard resource with the Remove-AzResource cmdlet using Az.Resource module version 10.x.x. with Windows Powershell 5.1 an exception is thrown: Remove-AzResource : The type initializer for 'ApiVersionCache' threw an exception.
Issue script & Debug output
Remove-AzResource -ResourceGroupName 'obtestazuresql-o-we-rg' -ResourceName 'obtestazuresql-o-we-dash' -ResourceType 'Microsoft.Portal/dashboards' -Force -Verbose
DEBUG: 11:28:25 AM - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning
default value [True].
DEBUG: 11:28:25 AM - RemoveAzureResourceCmdlet begin processing with ParameterSet 'BySubscriptionLevel'.
DEBUG: 11:28:25 AM - using account id 'xxxx'...
DEBUG: 11:28:25 AM - [ConfigManager] Got [True] from [DisplayBreakingChangeWarning], Module = [Az.Resources], Cmdlet =
[Remove-AzResource].
VERBOSE: Performing the operation "Deleting the resource..." on target
"/subscriptions/248b9b32-4c8c-49ad-8fd0-53cbad73d015/resourceGroups/obtestazuresql-o-we-rg/providers/Microsoft.Portal/d
ashboards/obtestazuresql-o-we-dash".
DEBUG: 11:28:25 AM - [ConfigManager] Got nothing from [EnableErrorRecordsPersistence], Module = [Az.Resources], Cmdlet
= [Remove-AzResource]. Returning default value [False].
Remove-AzResource : The type initializer for 'ApiVersionCache' threw an exception.
At line:1 char:1
+ Remove-AzResource -ResourceGroupName 'obtestazuresql-o-we-rg' -Resour ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Remove-AzResource], TypeInitializationException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.RemoveAzureResourceCmdle
t
DEBUG: 11:28:25 AM - [ConfigManager] Got [True] from [DisplayBreakingChangeWarning], Module = [Az.Resources], Cmdlet =
[Remove-AzResource].
DEBUG: 11:28:25 AM - [ConfigManager] Got [False] from [DisplayRegionIdentified], Module = [], Cmdlet = [].
DEBUG: 11:28:25 AM - [ConfigManager] Got nothing from [CheckForUpgrade], Module = [], Cmdlet = []. Returning default
value [True].
DEBUG: 11:28:25 AM - No authentication telemetry is found for the current cmdlet with Id
b4e64dc8-3e89-40fb-b7d5-fd43d1c675f0.
DEBUG: AzureQoSEvent: Module: Az.Resources:10.2.1; CommandName: Remove-AzResource; PSVersion: 5.1.26100.9444;
IsSuccess: False; Duration: 00:00:00.0244848; SanitizeDuration: 00:00:00; Exception: The type initializer for
'ApiVersionCache' threw an exception.;
DEBUG: 11:28:25 AM - [ConfigManager] Got [False] from [EnableDataCollection], Module = [], Cmdlet = [].
DEBUG: 11:28:25 AM - RemoveAzureResourceCmdlet end processing.Environment data
Name Value
---- -----
PSVersion 5.1.26100.9444
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.26100.9444
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1Module versions
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 5.5.3 Az.Accounts {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear...
Script 10.2.1 Az.Resources {Export-AzResourceGroup, Export-AzTemplateSpec, Get-AzDeny...Error output
DEBUG: 11:33:12 AM - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning
default value [True].
DEBUG: 11:33:12 AM - ResolveError begin processing with ParameterSet 'AnyErrorParameterSet'.
DEBUG: 11:33:12 AM - using account id 'xxx'...
DEBUG: 11:33:12 AM - [ConfigManager] Got [True] from [DisplayBreakingChangeWarning], Module = [Az.Accounts], Cmdlet =
[Resolve-AzError].
DEBUG: 11:33:12 AM - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning
default value [True].
HistoryId: 8
Message : The type initializer for 'ApiVersionCache' threw an exception.
StackTrace : at Microsoft.Azure.Commands.ResourceManager.Cmdlets.Components.ApiVersionHelper.ApiVersionCache.Get
CacheKey(String environmentName, String providerNamespace, String resourceType)
at Microsoft.Azure.Commands.ResourceManager.Cmdlets.Components.ApiVersionHelper.DetermineApiVersion
(IAzureContext context, String providerNamespace, String resourceType, Boolean pre)
at Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.ResourceManagerCmdletBaseWithApi
Version.DetermineApiVersion(String resourceId)
at Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.RemoveAzureResourceCmdlet.<>c__D
isplayClass4_0.<OnProcessRecord>b__0()
at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ConfirmAction(Boolean force,
String continueMessage, String processMessage, String target, Action action, Func`1 useShouldContinue)
at Microsoft.Azure.Commands.ResourceManager.Common.AzureRMCmdlet.ConfirmAction(Boolean force,
String continueMessage, String processMessage, String target, Action action)
at Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.RemoveAzureResourceCmdlet.OnProc
essRecord()
at Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.ResourceManagerCmdletBase.Execut
eCmdlet()
at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
Exception : System.TypeInitializationException
InvocationInfo : {Remove-AzResource}
Line : Remove-AzResource -ResourceGroupName 'obtestazuresql-o-we-rg' -ResourceName
'obtestazuresql-o-we-dash' -ResourceType 'Microsoft.Portal/dashboards' -Force
Position : At line:1 char:1
+ Remove-AzResource -ResourceGroupName 'obtestazuresql-o-we-rg' -Resour ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId : 8
DEBUG: 11:33:13 AM - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning
default value [True].
Message : Could not load file or assembly 'Microsoft.Extensions.Options, Version=2.2.0.0, Culture=neutral,
PublicKeyToken=adb9793829ddae60' or one of its dependencies. The system cannot find the file
specified.
StackTrace : at
Microsoft.Azure.Commands.ResourceManager.Cmdlets.Components.ApiVersionHelper.ApiVersionCache..cctor()
Exception : System.IO.FileNotFoundException
InvocationInfo : {Remove-AzResource}
Line : Remove-AzResource -ResourceGroupName 'obtestazuresql-o-we-rg' -ResourceName
'obtestazuresql-o-we-dash' -ResourceType 'Microsoft.Portal/dashboards' -Force
Position : At line:1 char:1
+ Remove-AzResource -ResourceGroupName 'obtestazuresql-o-we-rg' -Resour ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId : 8
DEBUG: 11:33:13 AM - [ConfigManager] Got [False] from [DisplayRegionIdentified], Module = [], Cmdlet = [].
DEBUG: 11:33:13 AM - [ConfigManager] Got nothing from [CheckForUpgrade], Module = [], Cmdlet = []. Returning default
value [True].
DEBUG: 11:33:13 AM - No authentication telemetry is found for the current cmdlet with Id
3ee552e0-78af-431f-8358-6009176df32c.
DEBUG: AzureQoSEvent: Module: Az.Accounts:5.5.3; CommandName: Resolve-AzError; PSVersion: 5.1.26100.9444; IsSuccess:
True; Duration: 00:00:00.1606525; SanitizeDuration: 00:00:00.0009148
DEBUG: 11:33:13 AM - [ConfigManager] Got [False] from [EnableDataCollection], Module = [], Cmdlet = [].
DEBUG: 11:33:13 AM - ResolveError end processing.Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
ARMact-identity-squadbugThis issue requires a change to an existing behavior in the product in order to be resolved.This issue requires a change to an existing behavior in the product in order to be resolved.customer-reported
Activity
microsoft-github-policy-service commentedon Sep 25, 2026
🔔 Routing this issue to @Azure/act-identity-squad.
x-engineering-agent commentedon Sep 25, 2026
Bug Analysis
Affected module:
Az.Resources(src/Resources/), not ResourceGraph. Target branch:main.Use this exact PR title:
[Resources] Fix Remove-AzResource API-version cache loading on Windows PowerShell 5.1Evidence and expected behavior
The report is sufficiently specified: Windows PowerShell 5.1.26100.9444, Desktop edition, CLR 4.0.30319.42000, Az.Resources 10.2.1, and Az.Accounts 5.5.3. The failing command is below; resource names have been replaced with variables:
With no explicit
-ApiVersion, deleting an existing dashboard should resolve a supported API version and perform the deletion. Instead,ApiVersionCachethrowsTypeInitializationException; the supplied inner exception isFileNotFoundExceptionforMicrosoft.Extensions.Options, Version=2.2.0.0or one of its dependencies. This is a client-side assembly-loading failure before the delete request, not evidence of a dashboard service failure. The concrete reported version is 10.2.1; this analysis does not establish that every 10.x version fails.Source-based diagnosis
Source was inspected at
fbd0af1011c9cb8d15b66b59f24ede820c501ee7:RemoveAzureResourceCmdlet.OnProcessRecordcallsDetermineApiVersionbeforeDeleteResource. The base implementation bypasses discovery only when-ApiVersionis supplied.ApiVersionHelper.DetermineApiVersionaccesses the cache. Its static initializer constructsMemoryCache(new MemoryCacheOptions()), matching the reported failing initializer.ResourceManager.csprojreferencesMicrosoft.Extensions.Caching.Memory2.2.0.Microsoft.Extensions.Options.dllamong required assemblies. Merely adding that manifest entry is not a fix. The unresolved point is whether the shipped dependency closure lacks the required assembly identity/dependency, or assembly binding/import order selects an incompatible version; source inspection alone cannot distinguish these.Focused correction
Inspect the resolved and shipped caching/Options dependency identities and the existing module-loading behavior on Windows PowerShell 5.1. Correct the module-scoped dependency/reference or loading mismatch so the cache's complete compatible dependency closure resolves in a clean supported host, including with Az.Accounts loaded. Start in the handwritten ResourceManager implementation/project and Resources packaging inputs; do not change unrelated services, hardcode a dashboard API version, suppress the initialization failure, or require users to change process-wide binding configuration. Preserve the cache's environment/provider/resource-type key, one-hour expiration, and existing default/stable/preview API-version selection behavior.
This path is handwritten, not an AutoRest-generated cmdlet. Avoid generated-file edits; if a durable AutoRest input does become necessary, follow the conditional generation protocol below.
Regression coverage for the queued fix
-ApiVersion, explicit-ApiVersionas a control, and a repeated cached lookup; retain current selection/fallback coverage. Do not hardcode subscription IDs, resource names, or locations, and keep scenario tests re-recordable.ResourceTypeApiVersionTestscurrently invokes the selection helpers by reflection, bypassing the cache initializer. Extend coverage beyond those helpers; existing removal scenarios are inResourceTests.cs.This is a triage handoff for durable queuing only; no implementation or tests were run during this triage.
Mandatory Codegen execution protocol
Before editing implementation files, inspect
src/Resources/and determine whether the affected cmdlet belongs to a*.Autorestproject. Classify the change before editing: REST schema and operation defects belong in the pinnedAzure/azure-rest-api-specsinput; PowerShell-specific public surface shaping belongs in the projectREADME.mddirectives; non-modelable client behavior belongs in handwrittencustom/; examples and tests remain handwritten. Do not directly synthesize or patch generated C#, proxy scripts,docs/, manifests, models, or the committed top-levelgenerated/tree.Use the Azure PowerShell repository's Codegen MCP documentation. Invoke its
generate-autoresttool with the absolute*.Autorestworking directory when that MCP tool is available. Otherwise execute the same repository-owned non-interactive sequence documented by the tool implementation:You MUST actually run Codegen after changing its durable inputs; do not merely describe these commands in the pull request. If the required tools cannot be installed or any generation step fails, stop and report the blocker instead of hand-authoring a substitute. Commit the complete generated diff, including a Codegen-created change to
generate-info.json(the exact filename; never fabricate itsgenerate_Id), then inspect the diff and run the focused module build, help, StaticAnalysis, and tests. A change confined to handwrittencustom/,examples/, or completed tests does not become generated merely because it is inside a*.Autorestproject.PR title & description (azure-powershell)
Follow CONTRIBUTING.md. azure-powershell does not enforce a strict title gate — it requires a clear, informative title and a fully filled-out PR template.
Suggested PR title (clear & informative;
[Module]prefix is the common convention):Required (per CONTRIBUTING.md):
Fixes #30201in the description so the PR auto-closes it.## Upcoming Releaseheader ofsrc/Resources/Resources/ChangeLog.md. Do not add a new version header.main.*.Autorestproject, run the repository's approved Codegen flow and include all regenerated artifacts, including that project's changedgenerate-info.json. Do not submit only hand-edited AutoRest source or generated output.src/Resources/).isra-fel commentedon Sep 30, 2026
The assembly that has trouble loading is Microsoft.Extensions.Options. It was added in #29654 as an intermideate dependency of
Azure.Identitylibrary.It seems it's also a dependency inside Az.Resources and caused the issue.
Will try to reproduce first.
Possible fixes:
Update: can reproduce with latest Az.Accounts and Az.Resources.
5.5.3 az.accounts
10.2.1 az.resources
Detailed log
microsoft-github-policy-service commentedon Oct 2, 2026
🔔 Routing this issue to @Azure/act-identity-squad.
microsoft-github-policy-service commentedon Oct 2, 2026
🔔 Routing this issue to @Azure/act-identity-squad.
x-engineering-agent commentedon Oct 2, 2026
Implementation Result
No pull request was opened because the implementation run completed without a validated code change.
The source analysis remains available above. A maintainer should confirm whether the issue is already resolved on the current target branch or provide the reproduction or root-cause evidence needed for another implementation request.
Posted by x-engineering-agent (Fixer)