Skip to content

fix: handle retired classicAdministrators API (InvalidResourceType 404) - #68

Open
SilvanBuehler wants to merge 1 commit into
Azure:masterfrom
SilvanBuehler:fix/classicAdministrators-InvalidResourceType
Open

fix: handle retired classicAdministrators API (InvalidResourceType 404)#68
SilvanBuehler wants to merge 1 commit into
Azure:masterfrom
SilvanBuehler:fix/classicAdministrators-InvalidResourceType

Conversation

@SilvanBuehler

Copy link
Copy Markdown

Problem

Microsoft retired Azure classic administrators on 2024-08-31 and the resource type has been fully removed as of May 2026. The endpoint now returns:

HTTP 404 Not Found
error.code    : InvalidResourceType
error.message : The resource type could not be found in the namespace
                'Microsoft.Authorization' for api version '2015-07-01'.

dataCollectionClassicAdministratorsSub called AzAPICall without an unhandledErrorAction parameter. AzAPICall 1.4.1 treats this unrecognised 404 as Stop, which raises a terminating error inside the -Parallel ForEach-Object block and kills the entire run for all subscriptions in the tenant.

First observed on a CSP subscription (quotaId CSP_2015-05-01), but not CSP-specific - the resource type is gone tenant-wide.

Fix

Two changes to dataCollectionClassicAdministratorsSub (in AzGovVizParallel.ps1 and dev/functions/dataCollection/dataCollectionFunctions.ps1):

1. Add unhandledErrorAction = 'ContinueQuiet' to the AzAPICall splat

Prevents the defunct endpoint from terminating the run. Matches the pattern already used by getDiagnosticSettingsMg, storage account calls, and other functions that encounter legitimately absent resource types.

2. Add 'InvalidResourceType' to the result guard

# Before
if ($AzApiCallResult -ne 'ClassicAdministratorListFailed') {

# After
if ($AzApiCallResult -ne 'ClassicAdministratorListFailed' -and $AzApiCallResult -ne 'InvalidResourceType') {

When the retired API returns InvalidResourceType, the subscription is silently skipped and no classic administrators entry is recorded - which is correct since the resource type no longer exists anywhere in Azure.

Reference

https://learn.microsoft.com/en-us/azure/role-based-access-control/classic-administrators

Microsoft retired Azure classic administrators on 2024-08-31 and the
resource type has been fully removed as of May 2026. The endpoint now
returns HTTP 404 with error.code InvalidResourceType.

dataCollectionClassicAdministratorsSub called AzAPICall without
unhandledErrorAction, so AzAPICall defaulted to Stop on this unhandled
404, raising a terminating error inside the -Parallel ForEach-Object
block and killing the entire run.

Two changes to dataCollectionClassicAdministratorsSub (AzGovVizParallel.ps1
and dev/functions/dataCollection/dataCollectionFunctions.ps1):

1. Add unhandledErrorAction = 'ContinueQuiet' to the AzAPICall splat so
   the defunct endpoint does not terminate the run.
2. Add 'InvalidResourceType' to the result guard alongside the existing
   'ClassicAdministratorListFailed' check so the subscription is silently
   skipped when AzAPICall returns that string.

Ref: https://learn.microsoft.com/en-us/azure/role-based-access-control/classic-administrators
@SilvanBuehler

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant