Skip to content

[dataprotection] Add autoprotection support for blob backup instances#9820

Open
Komla-Ansah wants to merge 2 commits intoAzure:mainfrom
Komla-Ansah:feature/autoprotection-blob-backup
Open

[dataprotection] Add autoprotection support for blob backup instances#9820
Komla-Ansah wants to merge 2 commits intoAzure:mainfrom
Komla-Ansah:feature/autoprotection-blob-backup

Conversation

@Komla-Ansah
Copy link
Copy Markdown

Description

Adds autoprotection support for blob backup instances in the \dataprotection\ CLI extension.

Changes

  • API version bump: Updated backup-instance create, update, validate-for-backup, and validate-for-update commands to API version 2026-03-01
  • New parameters: Added --auto-protection\ and --exclusion-prefixes\ to \initialize-backupconfig\ command for AzureBlob and AzureDataLakeStorage datasource types
  • Validation: Auto-protection is mutually exclusive with --container-list\ and --include-all-containers\
  • Tests: Added 9 unit tests covering positive scenarios (Blob/ADLS, with/without exclusion prefixes) and negative scenarios (invalid argument combinations)
  • Version bump: Extension version 1.9.0 1.10.0

Testing

  • All 9 new autoprotection tests pass
  • Linting (pylint, flake8) and CLI linter pass
  • Note: Some pre-existing recorded tests may fail in CI due to test subscription decommissioning (not related to this change)

Related

  • PowerShell parallel implementation: \New-AzDataProtectionBackupConfigurationClientObject\ with -AutoProtection\ switch

- Bump API version to 2026-03-01 for backup-instance create, update,
  validate-for-backup, and validate-for-update commands
- Add --auto-protection and --exclusion-prefixes parameters to
  initialize-backupconfig for AzureBlob and AzureDataLakeStorage
- Add get_blob_autoprotection_config helper with support for
  BlobBackupDatasourceParametersForAutoProtection and
  AdlsBlobBackupDatasourceParametersForAutoProtection object types
- Add validation: auto-protection is mutually exclusive with
  --container-list and --include-all-containers
- Add 9 unit tests covering positive and negative scenarios
- Bump extension version to 1.10.0

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@azure-client-tools-bot-prd
Copy link
Copy Markdown

Validation for Breaking Change Starting...

Thanks for your contribution!

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Apr 22, 2026

Thank you for your contribution! We will review the pull request and get back to you soon.

@github-actions
Copy link
Copy Markdown
Contributor

The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR.

Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

@github-actions
Copy link
Copy Markdown
Contributor

CodeGen Tools Feedback Collection

Thank you for using our CodeGen tool. We value your feedback, and we would like to know how we can improve our product. Please take a few minutes to fill our codegen survey

@github-actions
Copy link
Copy Markdown
Contributor

@Komla-Ansah Komla-Ansah marked this pull request as ready for review April 23, 2026 00:03
Copilot AI review requested due to automatic review settings April 23, 2026 00:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds auto-protection support for Azure Blob / ADLS backup-instance initialization in the dataprotection CLI extension, alongside an API version bump for backup-instance create/update/validate commands.

Changes:

  • Bumped backup-instance create/update/validate-for-backup/validate-for-update to API version 2026-03-01.
  • Added --auto-protection and --exclusion-prefixes to az dataprotection backup-instance initialize-backupconfig for AzureBlob and AzureDataLakeStorage, including mutual-exclusion validation.
  • Added scenario tests covering auto-protection configurations and invalid argument combinations; bumped extension version to 1.10.0.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/dataprotection/setup.py Bumps extension package version to 1.10.0.
src/dataprotection/HISTORY.rst Adds release notes entry for 1.10.0.
src/dataprotection/azext_dataprotection/manual/helpers.py Adds helper to generate blob auto-protection backupconfig payload.
src/dataprotection/azext_dataprotection/manual/custom.py Wires new auto-protection args into initialize-backupconfig and adds validation.
src/dataprotection/azext_dataprotection/manual/_params.py Adds CLI parameters --auto-protection and --exclusion-prefixes.
src/dataprotection/azext_dataprotection/manual/_help.py Adds help examples for auto-protection usage.
src/dataprotection/azext_dataprotection/tests/latest/test_dataprotection_configs.py Adds tests for auto-protection config output and invalid arg combos.
src/dataprotection/azext_dataprotection/aaz/latest/dataprotection/backup_instance/_create.py API version bump + schema additions for auto-protection settings.
src/dataprotection/azext_dataprotection/aaz/latest/dataprotection/backup_instance/_update.py API version bump + schema additions for auto-protection settings.
src/dataprotection/azext_dataprotection/aaz/latest/dataprotection/backup_instance/_validate_for_backup.py API version bump + schema additions for auto-protection settings.
src/dataprotection/azext_dataprotection/aaz/latest/dataprotection/backup_instance/_validate_for_update.py API version bump + schema additions for auto-protection settings.

if datasource_type == "AzureKubernetesService":
if any([vaulted_backup_containers, include_all_containers, storage_account_name, storage_account_resource_group]):
if any([vaulted_backup_containers, include_all_containers, storage_account_name, storage_account_resource_group,
auto_protection, auto_protection_exclusion_prefixes]):
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

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

The AKS datasource-type validation uses truthiness in any([... auto_protection, auto_protection_exclusion_prefixes]). With get_three_state_flag(), passing --auto-protection false results in False (falsy) and will not be rejected even though the parameter is not applicable to AKS. Consider checking explicit presence instead (e.g., is not None) for three-state flags to reliably reject unsupported parameters.

Suggested change
auto_protection, auto_protection_exclusion_prefixes]):
auto_protection is not None, auto_protection_exclusion_prefixes is not None]):

Copilot uses AI. Check for mistakes.
Comment on lines +127 to +131
if auto_protection:
if any([vaulted_backup_containers, include_all_containers]):
raise InvalidArgumentValueError('--auto-protection cannot be used with --container-list or --include-all-containers.')
if any([storage_account_name, storage_account_resource_group]):
raise InvalidArgumentValueError('--storage-account-name and --storage-account-resource-group are not applicable with --auto-protection.')
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

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

The mutual-exclusion checks under if auto_protection: use truthiness for include_all_containers (a three-state flag). If a user passes --include-all-containers false alongside --auto-protection true, the any([vaulted_backup_containers, include_all_containers]) check won’t catch it. Use explicit is not None / argument presence checks for three-state flags to ensure invalid combinations are consistently rejected.

Copilot uses AI. Check for mistakes.
Comment thread src/dataprotection/HISTORY.rst Outdated
@yonzhan yonzhan assigned calvinhzy and unassigned evelyn-ys Apr 23, 2026
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants