Skip to content

{Backup} Added support for Microsoft Defender for Cloud Source Scan configuration for Recovery Services vaults and Azure Virtual Machine backup items - #34076

Merged
Ethan Yang (necusjz) merged 13 commits into
Azure:devfrom
vidyadharijami:deve/vijami/mdcchanges
Sep 18, 2026

Conversation

@vidyadharijami

@vidyadharijami vidyadharijami commented Sep 14, 2026

Copy link
Copy Markdown
Member

🤖 PR Validation — ⚠️ Review suggested

Breaking Changes Tests
⚠️ None ️✔️ 130/130
⚠️AzureCLI-BreakingChangeTest
⚠️backup
rule cmd_name rule_message suggest_message
⚠️ 1011 - SubgroupAdd backup item source-scan-configuration sub group backup item source-scan-configuration added
⚠️ 1006 - ParaAdd backup vault update cmd backup vault update added parameter source_scan_state

Related command

az backup vault update
az backup item source-scan-configuration set
az backup item show
az backup recoverypoint show

Description

Adds Microsoft Defender for Cloud Source Scan configuration support for Recovery Services vaults and Azure VM backup items.

This PR adds --source-scan-state to az backup vault update and introduces az backup item source-scan-configuration set to enable or disable Source Scan for individual Azure VM backup items. It also surfaces Source Scan and recovery-point threat information, upgrades the Recovery Services Backup SDK to version 11.0.0 with API version 2026-07-01, and updates the related tests and recordings

Testing Guide

  1. Enable Source Scan on a Recovery Services vault. This configures the vault to support Microsoft Defender for Cloud Source Scan.
az backup vault update \
  --resource-group MyResourceGroup \
  --name MyVault \
  --source-scan-state Enabled

Verify the vault configuration:

az backup vault show \
  --resource-group MyResourceGroup \
  --name MyVault \
  --query properties.securitySettings.sourceScanConfiguration.state

Expected result: "Enabled".

  1. Enable Source Scan for an Azure VM backup item. The set command completes without output on success.
az backup item source-scan-configuration set \
  --resource-group MyResourceGroup \
  --vault-name MyVault \
  --container-name MyContainer \
  --name MyItem \
  --state Enabled \
  --backup-management-type AzureIaasVM \
  --workload-type VM

Verify the item-level Source Scan status:

az backup item show \
  --resource-group MyResourceGroup \
  --vault-name MyVault \
  --container-name MyContainer \
  --name MyItem \
  --backup-management-type AzureIaasVM \
  --workload-type VM \
  --query properties.sourceSideScanInfo

Expected result: sourceSideScanStatus eventually becomes Configured.

  1. View threat information for a scanned recovery point.
az backup recoverypoint show \
  --resource-group MyResourceGroup \
  --vault-name MyVault \
  --container-name MyContainer \
  --item-name MyItem \
  --name MyRecoveryPoint \
  --backup-management-type AzureIaasVM \
  --workload-type VM \
  --query "properties.{threatStatus:threatStatus,threatInfo:threatInfo}"

Expected result: the response contains populated threatStatus and threatInfo fields.

  1. Disable Source Scan for the backup item and vault.
az backup item source-scan-configuration set \
  --resource-group MyResourceGroup \
  --vault-name MyVault \
  --container-name MyContainer \
  --name MyItem \
  --state Disabled \
  --backup-management-type AzureIaasVM \
  --workload-type VM

az backup vault update \
  --resource-group MyResourceGroup \
  --name MyVault \
  --source-scan-state Disabled

History Notes

[Backup] az backup vault update: Add --source-scan-state to configure Microsoft Defender for Cloud Source Scan
[Backup] az backup item source-scan-configuration set: Add support for enabling or disabling Source Scan for Azure VM backup items


This checklist is used to make sure that common guidelines for a pull request are followed.

vidyadharijami and others added 9 commits August 25, 2026 12:24
…-delete)

custom_base.py:
- Restore containerSubscriptionId on the raw ARM item/recovery-point path, which
  regressed when `backup item`/`recoverypoint` show/list were repointed to the
  *_with_source_scan / *_with_threat_info wrappers (raw GET bypassed
  custom_help.set_container_subscription_id). Re-synthesize it from sourceResourceId.
- Make `backup item source-scan-configuration set` idempotent
  (SourceScanStatusAlreadyInRequestedState -> Succeeded).

test_backup_commands.py:
- source-scan test: retry container/item name resolution; the registered-container
  list is eventually consistent right after enable-for-vm and could return empty.
- vault soft-delete test: the ARG-backed `deleted-vault list-containers` does not
  surface the soft-deleted item within the test window, so make that check
  best-effort and keep the reliable undelete-lifecycle assertions; fix vm_found.
- rg_mapping: update resourceGuardOperationDetails expected count 14 -> 16.

test_ase_commands.py:
- Skip the two SAP ASE tests (permanent fixtures removed); tracked by WI 39504009.

Re-record affected cassettes and scrub the real subscription id from the
raw-path recordings.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Critical SDK deserialization and moderate serialization and test-coverage issues remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds Microsoft Defender for Cloud Source Scan configuration for Recovery Services vaults and Azure VM backup items, with Recovery Services SDK updates and expanded test coverage.

Changes:

  • Adds vault and item Source Scan commands, validation, and help.
  • Updates SDK dependencies, clients, models, and operation handling.
  • Updates tests, preparers, and recordings.
File summaries
File Change summary Final review note
src/azure-cli/setup.py Updates Recovery Services SDK dependencies.
src/azure-cli/requirements.py3.windows.txt Pins updated Windows packages.
src/azure-cli/requirements.py3.Linux.txt Pins updated Linux packages.
src/azure-cli/requirements.py3.Darwin.txt Pins updated Darwin packages.
src/azure-cli/azure/cli/command_modules/backup/tests/unit/test_custom.py Adds Source Scan unit tests. Moderate (2 votes): the module is not collected by normal backup test discovery.
src/azure-cli/azure/cli/command_modules/backup/tests/latest/test_sql_commands.py Updates SQL test resources and lookup logic.
src/azure-cli/azure/cli/command_modules/backup/tests/latest/test_backup_commands.py Adds vault, item, and recovery-point scenarios.
src/azure-cli/azure/cli/command_modules/backup/tests/latest/test_ase_commands.py Updates ASE test execution. Moderate (3 votes): newly skipped scenarios remove container and policy coverage.
src/azure-cli/azure/cli/command_modules/backup/tests/latest/recordings/test_backup_wl_sql_policy.yaml Refreshes SQL policy playback.
src/azure-cli/azure/cli/command_modules/backup/tests/latest/recordings/test_backup_wl_hana_snapshot.yaml Refreshes HANA snapshot playback.
src/azure-cli/azure/cli/command_modules/backup/tests/latest/recordings/test_backup_source_scan_recovery_points.yaml Adds Source Scan recovery-point playback.
src/azure-cli/azure/cli/command_modules/backup/tests/latest/recordings/test_backup_restore_multiple_containers_same_friendly_name.yaml Updates restore playback. Moderate (3 votes): playback starts with ResourceGroupNotFound, bypassing the intended validation path.
src/azure-cli/azure/cli/command_modules/backup/tests/latest/preparers.py Updates test preparation.
src/azure-cli/azure/cli/command_modules/backup/custom.py Implements vault Source Scan handling and SDK migration.
src/azure-cli/azure/cli/command_modules/backup/custom_wl.py Migrates workload operations to updated SDK handling.
src/azure-cli/azure/cli/command_modules/backup/custom_help.py Adds model, serialization, and operation helpers. Critical (1 vote): the fallback uses incompatible positional model construction and incorrect model types. Moderate (2 votes): synthetic resourceGroup is placed incorrectly for existing serialization and table checks.
src/azure-cli/azure/cli/command_modules/backup/custom_common.py Updates filtering and model handling.
src/azure-cli/azure/cli/command_modules/backup/custom_base.py Implements VM item Source Scan actions.
src/azure-cli/azure/cli/command_modules/backup/custom_afs.py Migrates Azure Files operations.
src/azure-cli/azure/cli/command_modules/backup/commands.py Registers Source Scan commands.
src/azure-cli/azure/cli/command_modules/backup/_validators.py Updates command argument validation.
src/azure-cli/azure/cli/command_modules/backup/_params.py Defines Source Scan arguments.
src/azure-cli/azure/cli/command_modules/backup/_help.py Documents commands and options.
src/azure-cli/azure/cli/command_modules/backup/_client_factory.py Updates active/passive Recovery Services client factories.
Review details

Suppressed comments (1)

src/azure-cli/azure/cli/command_modules/backup/tests/latest/test_ase_commands.py:94

  • This newly skips test_bkp_res_ase, removing its ASE backup/recovery coverage from the automated suite without adding a replacement. Please restore runnable test resources/recordings or keep the test-resource repair separate from this feature change.
  • Files reviewed: 25/67 changed files
  • Comments generated: 5
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/azure-cli/azure/cli/command_modules/backup/custom_help.py
Comment thread src/azure-cli/azure/cli/command_modules/backup/custom_help.py
@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

@yonzhan

Copy link
Copy Markdown
Collaborator

Backup

@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

@necusjz

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

@necusjz Ethan Yang (necusjz) changed the title [Backup] Added support for Microsoft Defender for Cloud Source Scan configuration for Recovery Services vaults and Azure Virtual Machine backup items {Backup} Added support for Microsoft Defender for Cloud Source Scan configuration for Recovery Services vaults and Azure Virtual Machine backup items Sep 17, 2026
@yanzhudd

Copy link
Copy Markdown
Contributor

please address above comments and also get approval from Zubair Abid (@zubairabid) as well.

@zubairabid Zubair Abid (zubairabid) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, overall. Main concern that remains: Due to the split Python SDK, there is now some fragility that might impact customers. The -passivestamp recoveryservicesbackup SDK needs to be installed after the main SDK is installed.

@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

@vidyadharijami

Copy link
Copy Markdown
Member Author

please address above comments and also get approval from Zubair Abid (Zubair Abid (@zubairabid)) as well.

Done

@necusjz
Ethan Yang (necusjz) merged commit b3ce5cd into Azure:dev Sep 18, 2026
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants