Skip to content

[Backup] Add Azure File Share cross-region restore and soft-delete undelete support - #33809

Open
bharatpurwar wants to merge 3 commits into
Azure:devfrom
bharatpurwar:bharatpurwar/afs-crr-6d028121
Open

[Backup] Add Azure File Share cross-region restore and soft-delete undelete support#33809
bharatpurwar wants to merge 3 commits into
Azure:devfrom
bharatpurwar:bharatpurwar/afs-crr-6d028121

Conversation

@bharatpurwar

@bharatpurwar bharatpurwar commented Jul 29, 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
⚠️ 1006 - ParaAdd backup restore restore-azurefileshare cmd backup restore restore-azurefileshare added parameter use_secondary_region

Related commands

az backup item list --use-secondary-region
az backup item show --use-secondary-region
az backup recoverypoint list --use-secondary-region
az backup restore restore-azurefileshare --use-secondary-region
az backup job show --use-secondary-region
az backup protection undelete

Description

Adds Azure File Share cross-region restore support for full-share alternate-location restores. The implementation resolves protected items and recovery points from the secondary region, validates the target file share, builds the passive-stamp CRR request with the Azure Storage access token, triggers the restore, and tracks the resulting CRR job.

Adds Azure File Share soft-delete undelete support. Soft-deleted Azure File Share protected items remain discoverable through item listing and can be rehydrated using az backup protection undelete. The command validates the deferred-delete state and submits the protected-item rehydrate request.

Also fixes Azure Storage CRR job formatting for task models without start/end timestamps.

Testing Guide

  • azdev test test_afs_cross_region_restore test_afs_backup_protection_undelete --series --no-exitfirst
  • azdev style backup
  • azdev linter backup

Both scenarios use recordings for CI playback. The undelete scenario uses transient resources through preparers and has a dedicated test_afs_backup_protection_undelete.yaml recording.

History Notes

[Backup] az backup restore restore-azurefileshare: Add Azure File Share cross-region restore support.

[Backup] az backup protection undelete: Add Azure File Share soft-delete undelete support.


Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 7a8ea165-11b7-4fc8-9919-ec589073b1fe
@bharatpurwar
bharatpurwar requested a review from a team as a code owner July 29, 2026 04:06
Copilot AI review requested due to automatic review settings July 29, 2026 04:06
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@microsoft-github-policy-service

Copy link
Copy Markdown
Contributor

🔔 Routing this PR to @Azure/act-observability-squad.

@a0x1ab

a0x1ab commented Jul 29, 2026

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

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

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.

Pull request overview

Adds Azure File Share cross-region restore (CRR) support to the backup command module, enabling --use-secondary-region for full-share alternate-location restores and validating target file shares before triggering the passive-stamp CRR workflow. Also adjusts CRR job/task formatting to tolerate task models missing timestamps and adds a record-only scenario test + recording.

Changes:

  • Enable CRR restore flow for Azure File Share restores via passive-stamp access token + CRR trigger, tracked as a CRR job.
  • Allow --use-secondary-region for AzureStorage recovery point listing and wire the flag through restore entrypoints/params.
  • Add playback-only scenario test and recording for the AFS CRR restore path; harden CRR task timestamp formatting.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/azure-cli/azure/cli/command_modules/backup/custom_afs.py Implements the AFS CRR restore path (passive stamp) and enables secondary-region recovery point listing; adds target file share validation.
src/azure-cli/azure/cli/command_modules/backup/custom_base.py Threads use_secondary_region into the restore_azurefileshare entrypoint and item resolution.
src/azure-cli/azure/cli/command_modules/backup/custom_common.py Allows AzureStorage to use --use-secondary-region by updating the “not supported” list.
src/azure-cli/azure/cli/command_modules/backup/custom_help.py Makes CRR task timestamp normalization resilient to missing start_time/end_time.
src/azure-cli/azure/cli/command_modules/backup/_params.py Adds --use-secondary-region to backup restore restore-azurefileshare.
src/azure-cli/azure/cli/command_modules/backup/_client_factory.py Introduces a Storage mgmt client factory and a file_shares_cf accessor used for target share validation.
src/azure-cli/azure/cli/command_modules/backup/tests/latest/test_afs_commands.py Adds a record-only scenario test covering AFS CRR restore and CRR job tracking.
src/azure-cli/azure/cli/command_modules/backup/tests/latest/recordings/test_afs_cross_region_restore.yaml Adds the test recording for the new scenario.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 18 to +25
from azure.cli.core.util import CLIError
from azure.cli.command_modules.backup._client_factory import protection_containers_cf, protectable_containers_cf, \
protection_policies_cf, backup_protection_containers_cf, backup_protectable_items_cf, \
resources_cf, backup_protected_items_cf, protected_items_cf
from azure.cli.core.azclierror import ArgumentUsageError, ValidationError
resources_cf, backup_protected_items_cf, protected_items_cf, \
recovery_points_crr_cf, recovery_points_passive_cf, aad_properties_cf, cross_region_restore_cf, vaults_cf, \
file_shares_cf
from azure.cli.core.azclierror import ArgumentUsageError, ValidationError, InvalidArgumentValueError
from azure.core.exceptions import ResourceNotFoundError
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 7a8ea165-11b7-4fc8-9919-ec589073b1fe
@bharatpurwar bharatpurwar changed the title [Backup] Add Azure File Share cross-region restore support [Backup] Add Azure File Share cross-region restore and soft-delete undelete support Aug 3, 2026
@a0x1ab

a0x1ab commented Aug 3, 2026

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

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

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

Copilot-Session: 7a8ea165-11b7-4fc8-9919-ec589073b1fe
@a0x1ab

a0x1ab commented Aug 3, 2026

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

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

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.

3 participants