Skip to content

[CosmosDB] Onboarding of backup and recovery experience#9745

Merged
calvinhzy merged 9 commits into
Azure:mainfrom
Shashank1306s:feature/cosmoscli
May 20, 2026
Merged

[CosmosDB] Onboarding of backup and recovery experience#9745
calvinhzy merged 9 commits into
Azure:mainfrom
Shashank1306s:feature/cosmoscli

Conversation

@Shashank1306s
Copy link
Copy Markdown
Contributor

@Shashank1306s Shashank1306s commented Mar 31, 2026


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

Related command

  • Added dataprotection support for AzureCosmosDB workload: new manifest (Microsoft.DocumentDB/databaseAccounts), registration in supported datasource types, datasource map, and permission help text.
  • Added end-to-end backup/restore scenario test, unit tests for default policy template, backup-instance initialize, and restore initialize, and an update-msi-permissions live test that grants Reader/Cosmos DB Operator on the data source RG / account.

General Guidelines

  • Have you run azdev style <YOUR_EXT> locally? (pip install azdev required)
  • Have you run python scripts/ci/test_index.py -q locally? (pip install wheel==0.30.0 required)
  • My extension version conforms to the Extension version schema

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.json automatically.
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.

SHASHANK SINGH and others added 3 commits February 26, 2026 10:12
- Add AzureCosmosDB manifest (Microsoft.DocumentDB/databaseAccounts)
- Register AzureCosmosDB in supported_datasource_types config
- Add CosmosDB to datasource_map in helpers
- Add unit tests for policy template, backup-instance initialize, restore initialize
- Add e2e test with recording for backup and restore scenario
@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd Bot commented Mar 31, 2026

⚠️Azure CLI Extensions Breaking Change Test
⚠️dataprotection
rule cmd_name rule_message suggest_message
⚠️ 1010 - ParaPropUpdate dataprotection backup-instance initialize cmd dataprotection backup-instance initialize update parameter datasource_type: updated property choices from ['AzureBlob', 'AzureDataLakeStorage', 'AzureDatabaseForMySQL', 'AzureDatabaseForPostgreSQL', 'AzureDatabaseForPostgreSQLFlexibleServer', 'AzureDisk', 'AzureKubernetesService'] to ['AzureBlob', 'AzureCosmosDB', 'AzureDataLakeStorage', 'AzureDatabaseForMySQL', 'AzureDatabaseForPostgreSQL', 'AzureDatabaseForPostgreSQLFlexibleServer', 'AzureDisk', 'AzureKubernetesService']
⚠️ 1010 - ParaPropUpdate dataprotection backup-instance initialize-backupconfig cmd dataprotection backup-instance initialize-backupconfig update parameter datasource_type: updated property choices from ['AzureBlob', 'AzureDataLakeStorage', 'AzureDatabaseForMySQL', 'AzureDatabaseForPostgreSQL', 'AzureDatabaseForPostgreSQLFlexibleServer', 'AzureDisk', 'AzureKubernetesService'] to ['AzureBlob', 'AzureCosmosDB', 'AzureDataLakeStorage', 'AzureDatabaseForMySQL', 'AzureDatabaseForPostgreSQL', 'AzureDatabaseForPostgreSQLFlexibleServer', 'AzureDisk', 'AzureKubernetesService']
⚠️ 1010 - ParaPropUpdate dataprotection backup-instance initialize-restoreconfig cmd dataprotection backup-instance initialize-restoreconfig update parameter datasource_type: updated property choices from ['AzureBlob', 'AzureDataLakeStorage', 'AzureDatabaseForMySQL', 'AzureDatabaseForPostgreSQL', 'AzureDatabaseForPostgreSQLFlexibleServer', 'AzureDisk', 'AzureKubernetesService'] to ['AzureBlob', 'AzureCosmosDB', 'AzureDataLakeStorage', 'AzureDatabaseForMySQL', 'AzureDatabaseForPostgreSQL', 'AzureDatabaseForPostgreSQLFlexibleServer', 'AzureDisk', 'AzureKubernetesService']
⚠️ 1010 - ParaPropUpdate dataprotection backup-instance list-from-resourcegraph cmd dataprotection backup-instance list-from-resourcegraph update parameter datasource_type: updated property choices from ['AzureBlob', 'AzureDataLakeStorage', 'AzureDatabaseForMySQL', 'AzureDatabaseForPostgreSQL', 'AzureDatabaseForPostgreSQLFlexibleServer', 'AzureDisk', 'AzureKubernetesService'] to ['AzureBlob', 'AzureCosmosDB', 'AzureDataLakeStorage', 'AzureDatabaseForMySQL', 'AzureDatabaseForPostgreSQL', 'AzureDatabaseForPostgreSQLFlexibleServer', 'AzureDisk', 'AzureKubernetesService']
⚠️ 1010 - ParaPropUpdate dataprotection backup-instance restore initialize-for-data-recovery cmd dataprotection backup-instance restore initialize-for-data-recovery update parameter datasource_type: updated property choices from ['AzureBlob', 'AzureDataLakeStorage', 'AzureDatabaseForMySQL', 'AzureDatabaseForPostgreSQL', 'AzureDatabaseForPostgreSQLFlexibleServer', 'AzureDisk', 'AzureKubernetesService'] to ['AzureBlob', 'AzureCosmosDB', 'AzureDataLakeStorage', 'AzureDatabaseForMySQL', 'AzureDatabaseForPostgreSQL', 'AzureDatabaseForPostgreSQLFlexibleServer', 'AzureDisk', 'AzureKubernetesService']
⚠️ 1010 - ParaPropUpdate dataprotection backup-instance restore initialize-for-data-recovery-as-files cmd dataprotection backup-instance restore initialize-for-data-recovery-as-files update parameter datasource_type: updated property choices from ['AzureBlob', 'AzureDataLakeStorage', 'AzureDatabaseForMySQL', 'AzureDatabaseForPostgreSQL', 'AzureDatabaseForPostgreSQLFlexibleServer', 'AzureDisk', 'AzureKubernetesService'] to ['AzureBlob', 'AzureCosmosDB', 'AzureDataLakeStorage', 'AzureDatabaseForMySQL', 'AzureDatabaseForPostgreSQL', 'AzureDatabaseForPostgreSQLFlexibleServer', 'AzureDisk', 'AzureKubernetesService']
⚠️ 1010 - ParaPropUpdate dataprotection backup-instance restore initialize-for-item-recovery cmd dataprotection backup-instance restore initialize-for-item-recovery update parameter datasource_type: updated property choices from ['AzureBlob', 'AzureDataLakeStorage', 'AzureDatabaseForMySQL', 'AzureDatabaseForPostgreSQL', 'AzureDatabaseForPostgreSQLFlexibleServer', 'AzureDisk', 'AzureKubernetesService'] to ['AzureBlob', 'AzureCosmosDB', 'AzureDataLakeStorage', 'AzureDatabaseForMySQL', 'AzureDatabaseForPostgreSQL', 'AzureDatabaseForPostgreSQLFlexibleServer', 'AzureDisk', 'AzureKubernetesService']
⚠️ 1010 - ParaPropUpdate dataprotection backup-instance update-msi-permissions cmd dataprotection backup-instance update-msi-permissions update parameter datasource_type: updated property choices from ['AzureBlob', 'AzureDataLakeStorage', 'AzureDatabaseForMySQL', 'AzureDatabaseForPostgreSQL', 'AzureDatabaseForPostgreSQLFlexibleServer', 'AzureDisk', 'AzureKubernetesService'] to ['AzureBlob', 'AzureCosmosDB', 'AzureDataLakeStorage', 'AzureDatabaseForMySQL', 'AzureDatabaseForPostgreSQL', 'AzureDatabaseForPostgreSQLFlexibleServer', 'AzureDisk', 'AzureKubernetesService']
⚠️ 1010 - ParaPropUpdate dataprotection backup-policy get-default-policy-template cmd dataprotection backup-policy get-default-policy-template update parameter datasource_type: updated property choices from ['AzureBlob', 'AzureDataLakeStorage', 'AzureDatabaseForMySQL', 'AzureDatabaseForPostgreSQL', 'AzureDatabaseForPostgreSQLFlexibleServer', 'AzureDisk', 'AzureKubernetesService'] to ['AzureBlob', 'AzureCosmosDB', 'AzureDataLakeStorage', 'AzureDatabaseForMySQL', 'AzureDatabaseForPostgreSQL', 'AzureDatabaseForPostgreSQLFlexibleServer', 'AzureDisk', 'AzureKubernetesService']
⚠️ 1010 - ParaPropUpdate dataprotection job list-from-resourcegraph cmd dataprotection job list-from-resourcegraph update parameter datasource_type: updated property choices from ['AzureBlob', 'AzureDataLakeStorage', 'AzureDatabaseForMySQL', 'AzureDatabaseForPostgreSQL', 'AzureDatabaseForPostgreSQLFlexibleServer', 'AzureDisk', 'AzureKubernetesService'] to ['AzureBlob', 'AzureCosmosDB', 'AzureDataLakeStorage', 'AzureDatabaseForMySQL', 'AzureDatabaseForPostgreSQL', 'AzureDatabaseForPostgreSQLFlexibleServer', 'AzureDisk', 'AzureKubernetesService']

@azure-client-tools-bot-prd
Copy link
Copy Markdown

Hi @Shashank1306s,
Please write the description of changes which can be perceived by customers into HISTORY.rst.
If you want to release a new extension version, please update the version in setup.py as well.

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Mar 31, 2026

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

@github-actions
Copy link
Copy Markdown
Contributor

The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR.

Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

@github-actions
Copy link
Copy Markdown
Contributor

CodeGen Tools Feedback Collection

Thank you for using our CodeGen tool. We value your feedback, and we would like to know how we can improve our product. Please take a few minutes to fill our codegen survey

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 31, 2026

@github-actions
Copy link
Copy Markdown
Contributor

Hi @Shashank1306s

Release Suggestions

Module: dataprotection

  • Please log updates into to src/dataprotection/HISTORY.rst
  • Update VERSION to 1.9.0 in src/dataprotection/setup.py

Notes

@yonzhan yonzhan assigned calvinhzy and unassigned evelyn-ys Mar 31, 2026
@jsntcy jsntcy requested a review from coopercox-ms April 7, 2026 04:33
Copy link
Copy Markdown
Contributor

@zubairabid zubairabid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the test file itself, and confirm that the update-msi-permissions command is not broken for the new workload.

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.

I can see the test recording, but not the test file itself - did we not commit that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added. please review

"addDataStoreParametersList": false,
"friendlyNameRequired": false,
"supportSecretStoreAuthentication": false,
"backupVaultPermissions": [
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.

Query: have we tested if the update-msi-permissions command works as expected with this set of permissions?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[update-msi-permissions] worked end-to-end and the permissions it set were exactly sufficient to complete configure-protection, adhoc-backup, and AlternateLocation restore

…ns test

- Add unit test file test_dataprotection_cosmosdb.py (was missing from earlier commit)

- Add live e2e Cosmos scenario test in test_dataprotection_backup_and_restore_workloads.py

- Add live test_dataprotection_update_msi_permissions_cosmosdb covering manifest backupVaultPermissions (Reader on DataSourceRG, Cosmos DB Operator on DataSource) using persistent cosmos-bugbash-CLIrg-6 accounts

- Update helpers.get_help_word_from_permission_type for AzureCosmosDB datasource label

- Bump dataprotection extension to 1.9.0 and update HISTORY.rst
@github-actions github-actions Bot added the release-version-block Updates do not qualify release version rules. NOTE: please do not edit it manually. label May 19, 2026
@github-actions github-actions Bot removed the release-version-block Updates do not qualify release version rules. NOTE: please do not edit it manually. label May 19, 2026
@Shashank1306s Shashank1306s marked this pull request as ready for review May 19, 2026 08:34
Copilot AI review requested due to automatic review settings May 19, 2026 08:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 onboards Azure Cosmos DB (account-level Microsoft.DocumentDB/databaseAccounts) as a supported workload in the dataprotection Azure CLI extension, including manifest registration, helper mappings, and scenario/unit test coverage for the backup/restore experience.

Changes:

  • Bumped the dataprotection extension version to 1.11.0 and added release notes.
  • Added an AzureCosmosDB manifest and wired it into supported datasource types + datasource mapping + permission help text.
  • Added Cosmos DB-focused tests (unit-style CLI payload validation + live scenario + live MSI permission update) and a new recording.

Reviewed changes

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

Show a summary per file
File Description
src/dataprotection/setup.py Bumps extension version to 1.11.0.
src/dataprotection/HISTORY.rst Adds 1.11.0 changelog entry for Cosmos DB onboarding and tests.
src/dataprotection/azext_dataprotection/manual/Manifests/config.py Registers AzureCosmosDB as a supported datasource type.
src/dataprotection/azext_dataprotection/manual/Manifests/AzureCosmosDB.py Adds the Cosmos DB workload manifest (policy + permissions + restore constraints).
src/dataprotection/azext_dataprotection/manual/helpers.py Adds Cosmos DB datasource mapping/help text; adds snake→camel override for resource_idresourceID.
src/dataprotection/azext_dataprotection/tests/latest/test_dataprotection_update_msi_permissions.py Adds a live-only Cosmos DB update-msi-permissions scenario.
src/dataprotection/azext_dataprotection/tests/latest/test_dataprotection_cosmosdb.py Adds unit-style CLI tests for default policy template, backup-instance initialize, and restore initialize outputs.
src/dataprotection/azext_dataprotection/tests/latest/test_dataprotection_backup_and_restore_workloads.py Adds a live-only end-to-end Cosmos DB backup + alternate-location restore scenario with explicit protection-status polling.
src/dataprotection/azext_dataprotection/tests/latest/recordings/test_dataprotection_backup_and_restore_cosmosdb.yaml Adds a recording for the Cosmos DB scenario.

Comment thread src/dataprotection/HISTORY.rst Outdated
Comment on lines +21 to +23
from azure.cli.testsdk import ScenarioTest
from azure.cli.testsdk.scenario_tests import AllowLargeResponse

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@calvinhzy calvinhzy changed the title Onboarding of backup and recovery experience for CosmosDB [CosmosDB] Onboarding of backup and recovery experience May 20, 2026
@calvinhzy
Copy link
Copy Markdown
Member

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 2 pipeline(s).

@calvinhzy
Copy link
Copy Markdown
Member

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 2 pipeline(s).

@Shashank1306s Shashank1306s requested a review from calvinhzy May 20, 2026 05:07
@Shashank1306s
Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Commenter does not have sufficient privileges for PR 9745 in repo Azure/azure-cli-extensions

@calvinhzy
Copy link
Copy Markdown
Member

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 2 pipeline(s).

@calvinhzy calvinhzy merged commit 195025e into Azure:main May 20, 2026
24 checks passed
@azclibot
Copy link
Copy Markdown
Collaborator

[Release] Update index.json for extension [ dataprotection-1.11.0 ] : https://dev.azure.com/msazure/One/_build/results?buildId=164892035&view=results

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Auto-Assign Auto assign by bot CosmosDB

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants