Skip to content

Added support for cost management settings#33757

Open
vidyadharijami wants to merge 6 commits into
Azure:devfrom
vidyadharijami:deve/vijami/clichanges
Open

Added support for cost management settings#33757
vidyadharijami wants to merge 6 commits into
Azure:devfrom
vidyadharijami:deve/vijami/clichanges

Conversation

@vidyadharijami

Copy link
Copy Markdown
Member

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.

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 on lines +347 to +353
if existing_vault is not None:
cost_management_settings = existing_vault.properties.cost_management_settings
else :
# Create scenario
cost_management_settings = CostManagementSettings()
cost_management_settings.granularity_level = "VaultLevel"

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

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.

6 participants