Skip to content

[Backup] Add support for cost management settings#33757

Merged
VeryEarly merged 20 commits into
Azure:devfrom
vidyadharijami:deve/vijami/clichanges
Jul 27, 2026
Merged

[Backup] Add support for cost management settings#33757
VeryEarly merged 20 commits into
Azure:devfrom
vidyadharijami:deve/vijami/clichanges

Conversation

@vidyadharijami

@vidyadharijami vidyadharijami commented Jul 21, 2026

Copy link
Copy Markdown
Member

Related command

az backup vault create and az backup vault update

Description

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.

🤖 PR Validation — ⚠️ Review suggested

Breaking Changes Tests
⚠️ None ️✔️ 130/130
⚠️AzureCLI-BreakingChangeTest
⚠️backup
rule cmd_name rule_message suggest_message
⚠️ 1006 - ParaAdd backup vault create cmd backup vault create added parameter cost_management_granularity
⚠️ 1006 - ParaAdd backup vault update cmd backup vault update added parameter cost_management_granularity

vidyadharijami and others added 4 commits July 17, 2026 10:24
… 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>
Copilot AI review requested due to automatic review settings July 21, 2026 05:33
@vidyadharijami
vidyadharijami requested review from a team as code owners July 21, 2026 05:33
@azure-client-tools-bot-prd

Copy link
Copy Markdown

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

@azure-pipelines

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

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 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-recoveryservices to 4.1.0 across setup and platform-specific requirements.
  • Add --cost-management-granularity support to az backup vault create/update, including defaulting to VaultLevel on create.
  • Update vault immutability update logic to include an ImmutabilityConfiguration when 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 thread src/azure-cli/azure/cli/command_modules/backup/custom.py
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']
@yonzhan

yonzhan commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

backup

@a0x1ab

a0x1ab commented Jul 22, 2026

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Command 'run

zubairabid and others added 8 commits July 24, 2026 14:05
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>
@VeryEarly

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

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

@VeryEarly

Copy link
Copy Markdown
Contributor

Hi @vidyadharijami , please resolve
image
and
image

@VeryEarly VeryEarly assigned VeryEarly and unassigned yanzhudd Jul 26, 2026
@a0x1ab

a0x1ab commented Jul 27, 2026

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

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

@a0x1ab

a0x1ab commented Jul 27, 2026

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

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

@vidyadharijami vidyadharijami changed the title Added support for cost management settings [Backup] Add support for cost management settings Jul 27, 2026
@a0x1ab

a0x1ab commented Jul 27, 2026

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

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

@VeryEarly
VeryEarly merged commit 7f56ca4 into Azure:dev Jul 27, 2026
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants