Skip to content

Fix in-flight export of Defender for Storage settings - #3927

Open
sary (sary8) wants to merge 2 commits into
Azure:mainfrom
sary8:fix/defender-for-storage-api-version
Open

sary (sary8) wants to merge 2 commits into
Azure:mainfrom
sary8:fix/defender-for-storage-api-version

Conversation

@sary8

@sary8 sary (sary8) commented Sep 19, 2026

Copy link
Copy Markdown

PR Summary

  • Change the api-version used to list Microsoft.Security/DefenderForStorageSettings during in-flight storage account export from 2022-12-01-preview to 2025-09-01-preview. The older version answers UnsupportedApiVersion for the collection request, so the sub-resource never lands in the export and a warning is written per storage account.
  • 2025-09-01-preview is the first version whose REST spec defines the collection LIST operation. The GA versions 2025-01-01 and 2025-06-01, and the 2024-08-01-preview suggested in the issue, define only .../DefenderForStorageSettings/{settingName}. The versions I tested are in my comment on the issue.
  • Rule results may change after re-exporting. Azure.Storage.Defender.MalwareScan and Azure.Storage.Defender.DataScan pass vacuously on in-flight data today and will start failing where the feature is off. Azure.Storage.DefenderCloud moves the other way.
  • Add a test for the api-version used by ResourceExpandVisitor.
  • Update the changelog.

Fixes #3865

Validation

  • Verified the collection request against a storage account in my subscription. The exported resource includes properties.isEnabled, properties.malwareScanning.onUpload.isEnabled and properties.sensitiveDataDiscovery.isEnabled.
  • dotnet test tests/PSRule.Rules.Azure.Tests/PSRule.Rules.Azure.Tests.csproj

PR Checklist

  • PR has a meaningful title
  • Summarized changes
  • Change is not breaking
  • This PR is ready to merge and is not Work in Progress
  • Rule changes
    • Unit tests created/ updated
    • Rule documentation created/ updated
    • Link to a filed issue
    • Change log has been updated with change under unreleased section
  • Other code changes
    • Unit tests created/ updated
    • Link to a filed issue
    • Change log has been updated with change under unreleased section

The collection GET for Microsoft.Security/DefenderForStorageSettings is
defined only in api-versions 2025-09-01-preview and 2026-01-01-preview.
The version in use, 2022-12-01-preview, and the GA versions 2025-01-01
and 2025-06-01 answer 400 UnsupportedApiVersion, so the sub-resource was
dropped from Export-AzRuleData output with a warning per storage account.

Fixes Azure#3865
@sary8
sary (sary8) requested a review from a team as a code owner September 19, 2026 02:35
Records requests through IResourceExportContext so the api-version used
for the DefenderForStorageSettings collection is asserted without calling
Azure.
@sary8
sary (sary8) force-pushed the fix/defender-for-storage-api-version branch from cc824b6 to ab923b4 Compare September 19, 2026 02:59
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.

Export-AzRuleData fails with HTTP 400 for DefenderForStorageSettings due to deprecated API version

1 participant