When running Export-AzRuleData, the following warning is emitted for every storage account in a subscription:
WARNING: Failed to get '.../Microsoft.Security/DefenderForStorageSettings
?api-version=2022-12-01-preview': status=400
{"error":{"code":"UnsupportedApiVersion","message":"The HTTP resource ...
does not support the API version '2022-12-01-preview'."}}
Root cause:
https://github.com/Azure/PSRule.Rules.Azure/tree/main/src/PSRule.Rules.Azure/Pipeline/Export/ResourceExpandVisitor.cs hardcodes "2022-12-01-preview" for the DefenderForStorageSettings sub-resource fetch:
AddSubResource(resource, await GetSubResourcesByProvider(
context, resourceId,
PROVIDER_TYPE_DEFENDER_FOR_STORAGE_SETTINGS,
"2022-12-01-preview", // deprecated
ignoreNotFound: true));
Microsoft has since retired this preview version on the regional Defender for Storage endpoint (*.storageav.azure.com). The repo's own data/providers/microsoft.security/types.json already lists 2024-08-01-preview as the current version.
Suggested fix: Update the hardcoded version in https://github.com/Azure/PSRule.Rules.Azure/tree/main/src/PSRule.Rules.Azure/Pipeline/Export/ResourceExpandVisitor.cs from "2022-12-01-preview" to "2024-08-01-preview".
Environment: PSRule.Rules.Azure v1.47.0, Az.Accounts v5.5.1
When running
Export-AzRuleData, the following warning is emitted for every storage account in a subscription:Root cause:
https://github.com/Azure/PSRule.Rules.Azure/tree/main/src/PSRule.Rules.Azure/Pipeline/Export/ResourceExpandVisitor.cs hardcodes
"2022-12-01-preview"for theDefenderForStorageSettingssub-resource fetch:Microsoft has since retired this preview version on the regional Defender for Storage endpoint (
*.storageav.azure.com). The repo's owndata/providers/microsoft.security/types.jsonalready lists2024-08-01-previewas the current version.Suggested fix: Update the hardcoded version in https://github.com/Azure/PSRule.Rules.Azure/tree/main/src/PSRule.Rules.Azure/Pipeline/Export/ResourceExpandVisitor.cs from
"2022-12-01-preview"to"2024-08-01-preview".Environment: PSRule.Rules.Azure v1.47.0, Az.Accounts v5.5.1