[DataProtection] Added support for cost management settings - #10280
[DataProtection] Added support for cost management settings#10280vidyadharijami wants to merge 2 commits into
Conversation
|
Hi vidyadharijami, |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Pull request overview
This PR updates the Data Protection extension to support Cost Management settings on Backup Vaults, alongside a broader refresh to the 2026-06-01 DataProtection management-plane API version and corresponding test/recording updates.
Changes:
- Add
--cost-management-granularitysupport toaz dataprotection backup-vault create/updateand includecostManagementSettings.granularityLevelin the AAZ schema. - Bump dataprotection backup-vault (and identity) AAZ commands from API version
2025-07-01to2026-06-01. - Update scenario tests/utilities and re-recordings to reflect new behavior (including improved job failure reporting).
Reviewed changes
Copilot reviewed 21 out of 32 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/dataprotection/azext_dataprotection/tests/utils.py | Improves job polling assertions to surface failure details and unexpected statuses. |
| src/dataprotection/azext_dataprotection/tests/latest/test_dataprotection_cosmosdb.py | Updates CosmosDB policy/template unit-test constants used to build example resource IDs. |
| src/dataprotection/azext_dataprotection/tests/latest/test_dataprotection_backup_vault.py | Extends backup-vault tests to validate cost management settings. |
| src/dataprotection/azext_dataprotection/tests/latest/test_dataprotection_backup_instance_operations.py | Updates scenario test parameters (subscription/policy IDs, etc.). |
| src/dataprotection/azext_dataprotection/tests/latest/test_dataprotection_backup_instance_create_and_delete.py | Updates scenario test parameters (location/subscription IDs). |
| src/dataprotection/azext_dataprotection/tests/latest/test_dataprotection_backup_and_restore_workloads.py | Adds “reuse existing” path for backup-instance validation and updates CosmosDB live scenario constants. |
| src/dataprotection/azext_dataprotection/tests/latest/recordings/test_dataprotection_backup_vault_list_from_resource_graph.yaml | Updates recording output to match current service/API responses. |
| src/dataprotection/azext_dataprotection/tests/latest/recordings/test_dataprotection_backup_policy_manual.yaml | Refreshes recording (API version/user-agent/response shape). |
| src/dataprotection/azext_dataprotection/tests/latest/recordings/test_dataprotection_backup_policy_create_and_delete.yaml | Refreshes recording (API version/user-agent/response shape). |
| src/dataprotection/azext_dataprotection/tests/latest/recordings/test_dataprotection_backup_instance_restore_blob_recovery_point.yaml | Refreshes recording (SDK/user-agent changes and response differences). |
| src/dataprotection/azext_dataprotection/tests/latest/recordings/test_dataprotection_backup_instance_list_from_resource_graph.yaml | Refreshes recording output to match current service/API responses. |
| src/dataprotection/azext_dataprotection/aaz/latest/dataprotection/backup_vault/identity/_wait.py | Moves identity wait to 2026-06-01 and adds costManagementSettings to schema. |
| src/dataprotection/azext_dataprotection/aaz/latest/dataprotection/backup_vault/identity/_show.py | Moves identity show to 2026-06-01 and adds costManagementSettings to schema. |
| src/dataprotection/azext_dataprotection/aaz/latest/dataprotection/backup_vault/identity/_remove.py | Moves identity remove to 2026-06-01 and adds deleted-vault header + schema updates. |
| src/dataprotection/azext_dataprotection/aaz/latest/dataprotection/backup_vault/identity/_assign.py | Moves identity assign to 2026-06-01 and adds deleted-vault header + schema updates. |
| src/dataprotection/azext_dataprotection/aaz/latest/dataprotection/backup_vault/_wait.py | Moves vault wait to 2026-06-01 and adds costManagementSettings to schema. |
| src/dataprotection/azext_dataprotection/aaz/latest/dataprotection/backup_vault/_update.py | Adds cost management arg + request mapping; bumps API version; adds deleted-vault header. |
| src/dataprotection/azext_dataprotection/aaz/latest/dataprotection/backup_vault/_show.py | Moves vault show to 2026-06-01 and adds costManagementSettings to schema. |
| src/dataprotection/azext_dataprotection/aaz/latest/dataprotection/backup_vault/_list.py | Moves vault list to 2026-06-01 and adds costManagementSettings to schema. |
| src/dataprotection/azext_dataprotection/aaz/latest/dataprotection/backup_vault/_delete.py | Moves vault delete to 2026-06-01. |
| src/dataprotection/azext_dataprotection/aaz/latest/dataprotection/backup_vault/_create.py | Adds cost management arg + request mapping; bumps API version; adds deleted-vault header. |
Suppressed comments (2)
src/dataprotection/azext_dataprotection/tests/latest/test_dataprotection_backup_instance_operations.py:84
- This test is not marked @live_only(), but it hardcodes a specific subscription ID and switches the CLI context via
az account set. In playback/CI this commonly fails because the test profile won’t contain that subscription, and it also bakes a real subscription GUID into the repo. Prefer using the active test subscription and avoid forcing an account switch (then re-record/sanitize as needed).
test.kwargs.update({
'subscriptionId': '38304e13-357e-405e-9e9a-220351dcce8c',
'originalSubscriptionId': test.cmd('az account show --query id -o tsv').output.strip(),
'rg': 'clitest-dpp-rg',
'vaultName': 'clitest-bkp-vault-donotdelete',
'backupInstanceName': 'clitestblobvijami-clitestblobvijami-92e88a05-3816-418b-8987-1285f34c2030',
'policyName': 'blobpolicy',
'policyId': '/subscriptions/38304e13-357e-405e-9e9a-220351dcce8c/resourceGroups/clitest-dpp-rg/providers/Microsoft.DataProtection/backupVaults/clitest-bkp-vault-donotdelete/backupPolicies/blobpolicy',
'altPolicyName': 'altvaultpolicy',
'altPolicyId': '/subscriptions/38304e13-357e-405e-9e9a-220351dcce8c/resourceGroups/clitest-dpp-rg/providers/Microsoft.DataProtection/backupVaults/clitest-bkp-vault-donotdelete/backupPolicies/altvaultpolicy'
})
test.addCleanup(lambda: test.cmd('az account set --subscription "{originalSubscriptionId}"'))
test.cmd('az account set --subscription "{subscriptionId}"')
test.cmd('az dataprotection backup-instance wait -g "{rg}" --vault-name "{vaultName}" --backup-instance-name "{backupInstanceName}" --timeout 300 '
src/dataprotection/azext_dataprotection/tests/latest/test_dataprotection_backup_instance_create_and_delete.py:69
- This test is not marked @live_only(), but it hardcodes a specific subscription ID and calls
az account setto switch context. That will typically break playback/CI (subscription not present in the mocked profile) and leaks a real subscription GUID into the repo. Prefer using the active subscription and avoid forcing the switch, then re-record/sanitize recordings if needed.
test.kwargs.update({
'subscriptionId': '38304e13-357e-405e-9e9a-220351dcce8c',
'originalSubscriptionId': test.cmd('az account show --query id -o tsv').output.strip(),
'dataSourceType': "AzureDisk",
'permissionsScope': "Resource",
'policyId': '/subscriptions/38304e13-357e-405e-9e9a-220351dcce8c/resourceGroups/clitest-dpp-rg/providers/Microsoft.DataProtection/backupVaults/clitest-bkp-vault-donotdelete/backupPolicies/diskpolicy',
'diskName': 'clitest-disk-donotdelete',
'diskId': '/subscriptions/38304e13-357e-405e-9e9a-220351dcce8c/resourceGroups/clitest-dpp-rg/providers/Microsoft.Compute/disks/clitest-disk-donotdelete',
'policyRuleName': "BackupHourly"
})
test.addCleanup(lambda: test.cmd('az account set --subscription "{originalSubscriptionId}"'))
test.cmd('az account set --subscription "{subscriptionId}"')
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| SUBSCRIPTION_ID = '38304e13-357e-405e-9e9a-220351dcce8c' | ||
| RESOURCE_GROUP = 'cosmosbugbash-vijami-rg' | ||
| SOURCE_COSMOS_NAME = 'cosmosbugbash-vijami-src3' | ||
| TARGET_COSMOS_NAME = 'cosmosbugbash-vijami-tgt2' |
| - nosniff | ||
| x-ms-arm-resource-system-data: | ||
| - '{"lastModifiedBy":"ianna@microsoft.com","lastModifiedByType":"User","lastModifiedAt":"2025-11-04T08:56:26.9783883Z"}' | ||
| - '{"lastModifiedBy":"vijami@microsoft.com","lastModifiedByType":"User","lastModifiedAt":"2026-08-31T07:02:26.2004809Z"}' |
| - nosniff | ||
| x-ms-arm-resource-system-data: | ||
| - '{"lastModifiedBy":"ianna@microsoft.com","lastModifiedByType":"User","lastModifiedAt":"2026-05-19T05:02:16.1055522Z"}' | ||
| - '{"lastModifiedBy":"vijami@microsoft.com","lastModifiedByType":"User","lastModifiedAt":"2026-08-31T07:02:41.1666376Z"}' |
| code: 202 | ||
| message: Accepted | ||
| - request: | ||
| body: '{"subscriptions": ["38304e13-357e-405e-9e9a-220351dcce8c"], "query": "RecoveryServicesResources |
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
🤖 PR Validation —⚠️ Review suggested
This checklist is used to make sure that common guidelines for a pull request are followed.
Related command
General Guidelines
azdev style <YOUR_EXT>locally? (pip install azdevrequired)python scripts/ci/test_index.py -qlocally? (pip install azdevrequired)For new extensions:
About Extension Publish
There is a pipeline to automatically build, upload and publish extension wheels.
Once your pull request is merged into main branch, a new pull request will be created to update
src/index.jsonautomatically.You only need to update the version information in file setup.py and historical information in file HISTORY.rst in your PR but do not modify
src/index.json.