[Backup] Add Azure File Share cross-region restore and soft-delete undelete support - #33809
[Backup] Add Azure File Share cross-region restore and soft-delete undelete support#33809Bharat Purwar (bharatpurwar) wants to merge 4 commits into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 7a8ea165-11b7-4fc8-9919-ec589073b1fe
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
🔔 Routing this PR to @Azure/act-observability-squad. |
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
There was a problem hiding this comment.
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-regionfor 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.
| 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
|
/azp run |
|
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
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
|
/azp run Azure.azure-cli |
|
Commenter does not have sufficient privileges for PR 33809 in repo Azure/azure-cli |
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
|
Hi Team, please review the changes |
Zubair Abid (zubairabid)
left a comment
There was a problem hiding this comment.
Look good, minor changes unrelated to function.
| # CRR path: route through passive stamp (secondary region endpoint) | ||
| if use_secondary_region: | ||
| vault = vaults_cf(cmd.cli_ctx).get(resource_group_name, vault_name) | ||
| import azure.cli.command_modules.backup.custom as custom_module |
There was a problem hiding this comment.
nit: move imports to top of file.
There was a problem hiding this comment.
fixed
| recovery_points = client.list(vault_name, resource_group_name, fabric_name, container_uri, item_uri, filter_string) | ||
| paged_recovery_points = helper.get_list_from_paged_response(recovery_points) | ||
| if use_secondary_region: | ||
| crr_client = recovery_points_crr_cf(cmd.cli_ctx) |
There was a problem hiding this comment.
nit: having both this and the previous cross_region_restore_cf instance be called crr_client can get a bit confusing, useful to disambiguate the naming a bit.
There was a problem hiding this comment.
fixed
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 7a8ea165-11b7-4fc8-9919-ec589073b1fe
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
🤖 PR Validation —⚠️ Review suggested
Related commands
az backup item list --use-secondary-regionaz backup item show --use-secondary-regionaz backup recoverypoint list --use-secondary-regionaz backup restore restore-azurefileshare --use-secondary-regionaz backup job show --use-secondary-regionaz backup protection undeleteDescription
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-exitfirstazdev style backupazdev linter backupBoth scenarios use recordings for CI playback. The undelete scenario uses transient resources through preparers and has a dedicated
test_afs_backup_protection_undelete.yamlrecording.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.