Skip to content

{backup} az backup Fix live testing using storage accounts and improve RG teardown#33749

Open
zubairabid wants to merge 2 commits into
Azure:devfrom
zubairabid:zubair/maintenance
Open

{backup} az backup Fix live testing using storage accounts and improve RG teardown#33749
zubairabid wants to merge 2 commits into
Azure:devfrom
zubairabid:zubair/maintenance

Conversation

@zubairabid

Copy link
Copy Markdown
Contributor

Related command

Description

Testing Guide

History Notes

[Component Name 1] BREAKING CHANGE: az command a: Make some customer-facing breaking change
[Component Name 2] az command b: Add some customer-facing feature


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

… RG teardown

The BCDR_StorageAccount_RequiredTags deny policy (management-group scope) blocks
the untagged storage account created by the test preparer, and the GPv1 'Storage'
kind is no longer allowed for new accounts. Add a self-contained
StorageAccountPreparer that creates the account with the required tags
(DisableLocalAuth=false, Reason, ETA, Owner) and kind StorageV2.

Consolidate to a single custom ResourceGroupPreparer (subclass of the testsdk
preparer) whose teardown clears any resource locks and retries on ScopeLocked,
since Azure Backup releases the AFS storage-account CanNotDelete lock
asynchronously. Remove the unused RGPreparer stopgap.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@zubairabid
zubairabid requested a review from a team as a code owner July 20, 2026 05:53
Copilot AI review requested due to automatic review settings July 20, 2026 05:53
@azure-client-tools-bot-prd

Copy link
Copy Markdown
Validation for Azure CLI Full Test Starting...

Thanks for your contribution!

@azure-client-tools-bot-prd

Copy link
Copy Markdown

Hi @zubairabid,
Since the current milestone time is less than 7 days, this pr will be reviewed in the next milestone.

@azure-client-tools-bot-prd

Copy link
Copy Markdown
Validation for Breaking Change Starting...

Thanks for your contribution!

@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 microsoft-github-policy-service Bot added the customer-reported Issues that are reported by GitHub users external to the Azure organization. label Jul 20, 2026
@microsoft-github-policy-service

Copy link
Copy Markdown
Contributor

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

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

This PR updates the az backup command module’s scenario-test infrastructure to make live testing more reliable when tests need to create storage accounts (e.g., under management-group tag policies) and to make resource group teardown more resilient to Azure Backup’s asynchronous lock behavior.

Changes:

  • Introduces backup-specific test preparers for storage accounts (policy-required tags, StorageV2) and resource groups (lock cleanup + retry on ScopeLocked).
  • Updates AFS backup tests to use the local custom preparers rather than the generic testsdk ones.
  • Refactors imports in backup test suites to align with the new preparer implementations.

Reviewed changes

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

File Description
src/azure-cli/azure/cli/command_modules/backup/tests/latest/test_backup_commands.py Adjusts preparer imports; currently still uses testsdk StorageAccountPreparer (needs alignment with new custom preparer).
src/azure-cli/azure/cli/command_modules/backup/tests/latest/test_afs_commands.py Switches to using custom ResourceGroupPreparer/StorageAccountPreparer from .preparers for live testing.
src/azure-cli/azure/cli/command_modules/backup/tests/latest/preparers.py Adds custom preparers: storage account creation with required tags and improved RG teardown handling lock races.

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

@yonzhan

yonzhan commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

backup

…uard op count

Use the backup-local StorageAccountPreparer (StorageV2 + BCDR-required tags) in
test_backup_commands.py so the VM/CRR/restore tests' storage accounts satisfy the
BCDR_StorageAccount_RequiredTags deny policy (clears the RequestDisallowedByPolicy
failures). Bump test_backup_rg_mapping's expected resourceGuardOperationDetails
from 9 to 14 to match the current service critical-operations set (adds
backupCrossTenantVaultMappings/* and immutability duration/state operations).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

act-codegen-extensibility-squad act-observability-squad Auto-Assign Auto assign by bot Backup customer-reported Issues that are reported by GitHub users external to the Azure organization. Storage az storage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants