[Backup] Add support for cost management settings#33757
Merged
Conversation
… 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>
…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>
|
Hi @vidyadharijami, |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Azure CLI Backup module to support configuring Recovery Services Vault cost management settings (granularity) and aligns the Recovery Services management SDK dependency to a newer version needed for the updated vault models.
Changes:
- Bump
azure-mgmt-recoveryservicesto4.1.0across setup and platform-specific requirements. - Add
--cost-management-granularitysupport toaz backup vault create/update, including defaulting toVaultLevelon create. - Update vault immutability update logic to include an
ImmutabilityConfigurationwhen enabling immutability, and extend tests to validate cost management behavior.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/azure-cli/setup.py | Updates azure-mgmt-recoveryservices dependency range to ~=4.1.0. |
| src/azure-cli/requirements.py3.windows.txt | Pins azure-mgmt-recoveryservices==4.1.0 for Windows builds. |
| src/azure-cli/requirements.py3.Linux.txt | Pins azure-mgmt-recoveryservices==4.1.0 for Linux builds. |
| src/azure-cli/requirements.py3.Darwin.txt | Pins azure-mgmt-recoveryservices==4.1.0 for macOS builds. |
| src/azure-cli/azure/cli/command_modules/backup/custom.py | Implements cost management settings update/create plumbing and immutability configuration handling. |
| src/azure-cli/azure/cli/command_modules/backup/_params.py | Exposes the new --cost-management-granularity enum parameter for create/update. |
| src/azure-cli/azure/cli/command_modules/backup/tests/latest/test_backup_commands.py | Adds assertions and update coverage for cost management granularity. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+222
to
+228
| return update_vault(cmd, client, vault_name, resource_group_name, tags=tags, | ||
| public_network_access=public_network_access, | ||
| immutability_state=immutability_state, | ||
| cross_subscription_restore_state=cross_subscription_restore_state, | ||
| classic_alerts=classic_alerts, | ||
| azure_monitor_alerts_for_job_failures=azure_monitor_alerts_for_job_failures, | ||
| cost_management_granularity=cost_management_granularity) |
| allowed_rehyd_priority_type = ['Standard', 'High'] | ||
| allowed_softdelete_options = ['Enable', 'Disable', 'AlwaysOn'] | ||
| allowed_immutability_options = ['Disabled', 'Locked', 'Unlocked'] | ||
| allowed_granularitylevel_options = ['VaultLevel','ProtectedItemLevel','ProtectedItemWithParentTag'] |
…ure-cli into deve/vijami/clichanges
Collaborator
|
backup |
…ure-cli into deve/vijami/clichanges
Member
|
/azp run |
| Command 'run |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The KeyVaultPreparer was pinned to --enable-rbac-authorization false (Access-Policy mode) by commit cd9a1ae (Azure#31288), but the CMK encryption identities are granted via RBAC role assignments (Key Vault Crypto Service Encryption User). AP-mode vaults ignore RBAC assignments, so 'backup vault encryption update' failed live with 403 UserErrorCMKKeyVaultAuthFailure. Flip the preparer to --enable-rbac-authorization true so the (live-only) RBAC grants take effect. Grants stay commented because role assignments use non-deterministic GUIDs that cannot be recorded/replayed; re-recorded the cassette. Verified: playback passes, live passes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ary) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…api-version 2026-05-01) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…gs for recoveryservices SDK 4.1.0 (api-version 2026-05-01) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
Contributor
|
Hi @vidyadharijami , please resolve |
…hen_storage) for recoveryservices SDK 4.1.0
Update backup test recordings for recoveryservices SDK 4.1.0
Member
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
Member
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
Member
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
VeryEarly
approved these changes
Jul 27, 2026
yanzhudd
approved these changes
Jul 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Related command
az backup vault createandaz backup vault updateDescription
Added support to enable Azure Backup customers to choose the granularity level at which their backup costs appear in Azure Cost Management.
Testing Guide
History Notes
[Backup] Add support for cost management settings
This checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.
🤖 PR Validation —⚠️ Review suggested