Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
c4007f1
Added generated Python SDK for 2026-04-01-preview
pjohari-ms Apr 30, 2026
8be9a5e
Add soft-delete CLI support for SQL databases and containers
mohhef May 21, 2026
7eb8baa
Add missing soft-delete command wiring (client factories, params, hel…
mohhef May 26, 2026
610db44
Add soft-delete params to cosmosdb create/update commands
mohhef May 26, 2026
c85eee2
Add HISTORY.rst changelog and linter exclusions for soft-delete
mohhef May 26, 2026
48ab9da
Re-record soft-delete tests on public AzureCloud with API version 202…
mohhef May 29, 2026
dcff859
Revert SqlResourcesOperations redirect (unrelated to soft-delete)
mohhef Jun 4, 2026
b9b649e
Add Continuous35Days backup tier support for CosmosDB
vinhms Jun 8, 2026
675a197
Update HISTORY.rst with Continuous35Days entry
vinhms Jun 8, 2026
bd6d9bc
Add test recordings and fix SDK import for ManagedServiceIdentityUser…
vinhms Jun 8, 2026
b64afe9
Merge pull request #10 from vinhms/pitr35-cli
pjohari-ms Jun 16, 2026
8508393
Merge base branch cdb260401preview to resolve conflicts
mohhef Jun 19, 2026
e28d2da
Use azure.mgmt.cosmosdb import path for soft-delete SDK classes
mohhef Jun 19, 2026
2ba3b54
Combine soft-delete update params into a single --soft-delete-config arg
mohhef Jun 19, 2026
c7f8605
Merge pull request #8 from mohhef/softdelete-cli-v10sdk
pjohari-ms Jun 21, 2026
baa26b2
Updated SDK
pjohari-ms Jun 21, 2026
cb00dcf
Merge branch 'cdb260401preview' of https://github.com/pjohari-ms/azur…
pjohari-ms Jun 21, 2026
4557cf5
[CosmosDB] Adapt extension code to regenerated SDK (2026-04-01-preview)
pjohari-ms Jun 22, 2026
a223e03
[CosmosDB] Re-record tests for API version 2026-04-01-preview
pjohari-ms Jun 22, 2026
90d2244
[CosmosDB] Re-record PITR restore tests for API version 2026-04-01-pr…
pjohari-ms Jun 23, 2026
b7c2504
[CosmosDB] Mark env-dependent tests as live-only
pjohari-ms Jun 23, 2026
0f3a105
[CosmosDB] Re-record table account restore test for API version 2026-…
pjohari-ms Jun 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions linter_exclusions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3618,3 +3618,11 @@ relationship dependency-of create:
relationship service-group-member create:
rule_exclusions:
- missing_command_example

cosmosdb sql softdeleted-database list:
rule_exclusions:
- no_ids_for_list_commands

cosmosdb sql softdeleted-container list:
rule_exclusions:
- no_ids_for_list_commands
8 changes: 8 additions & 0 deletions src/cosmosdb-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
Release History
===============

1.7.0
++++++
* Add support for soft-deleted resource operations for SQL API
* New command group `az cosmosdb softdeleted-account` to list, show, delete (purge), and recover soft-deleted accounts
* New command group `az cosmosdb sql softdeleted-database` to list, show, delete (purge), and recover soft-deleted databases
* New command group `az cosmosdb sql softdeleted-container` to list, show, delete (purge), and recover soft-deleted containers
* Add support for new Continuous 35 Days backup mode (PITR Premium).

1.6.2
* Added throughput bucketing.
+++++++
Expand Down
21 changes: 21 additions & 0 deletions src/cosmosdb-preview/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ This package provides commands to
- Update an Azure Cosmos DB database account to enable materialized views
- Create/Delete a cosmosdb materialized views builder service resource
- Provision and update database account with Continuous 7 days backup mode
- Provision and update database account with Continuous 35 days backup mode
- Retrieve and redistribute throughput at physical partition level.
- Create a new Azure Cosmos DB database account with burst capacity.
- Update an Azure Cosmos DB database account to enable/disable burst capacity.
Expand Down Expand Up @@ -44,6 +45,16 @@ az cosmosdb create \
--continuous-tier "Continuous7Days"
```

#### Create a new CosmosDB continuous backup Account with 35 days retention ####

```sh
az cosmosdb create \
--resource-group "my-rg" \
--name "my-continuous-backup-account" \
--backup-policy-type "Continuous"
--continuous-tier "Continuous35Days"
```

#### Convert a periodic backup policy CosmosDB account to continuous backup Account ####

```sh
Expand All @@ -63,6 +74,16 @@ az cosmosdb update \
--continuous-tier "Continuous7Days"
```

#### Convert a periodic backup policy CosmosDB account to continuous backup Account with 35 days retention ####

```sh
az cosmosdb update \
--resource-group "my-rg" \
--name "my-continuous-backup-account" \
--backup-policy-type "Continuous" \
--continuous-tier "Continuous35Days"
```

#### List all the CosmosDB accounts that can be restored (live and deleted) ####

This command returns all the continuous mode backup accounts that can be restored.
Expand Down
13 changes: 13 additions & 0 deletions src/cosmosdb-preview/azext_cosmosdb_preview/_client_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,16 @@ def cf_fleetspace_account(cli_ctx, _):

def cf_fleet_analytics(cli_ctx, _):
return cf_cosmosdb_preview(cli_ctx).fleet_analytics


# soft-deleted resources
def cf_softdeleted_database_accounts(cli_ctx, _):
return cf_cosmosdb_preview(cli_ctx).soft_deleted_database_accounts


def cf_softdeleted_sql_databases(cli_ctx, _):
return cf_cosmosdb_preview(cli_ctx).soft_deleted_sql_databases


def cf_softdeleted_sql_containers(cli_ctx, _):
return cf_cosmosdb_preview(cli_ctx).soft_deleted_sql_containers
130 changes: 130 additions & 0 deletions src/cosmosdb-preview/azext_cosmosdb_preview/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,10 @@
text: az cosmosdb update --capabilities EnableGremlin --name MyCosmosDBDatabaseAccount --resource-group MyResourceGroup
- name: Update an Azure Cosmos DB database account to enable materialized views.
text: az cosmosdb update --name MyCosmosDBDatabaseAccount --resource-group MyResourceGroup --enable-materialized-views true
- name: Enable soft deletion on the account with a 1440 minutes (24 hours) retention period.
text: az cosmosdb update --name MyCosmosDBDatabaseAccount --resource-group MyResourceGroup --soft-delete-config '{"softDeletionEnabled":true,"softDeleteRetentionPeriodInMinutes":1440,"minMinutesBeforePermanentDeletionAllowed":60}'
- name: Configure soft deletion on the account from a JSON file.
text: az cosmosdb update --name MyCosmosDBDatabaseAccount --resource-group MyResourceGroup --soft-delete-config @soft-delete-config.json
"""

# restore account
Expand Down Expand Up @@ -1844,3 +1848,129 @@
type: command
short-summary: Delete a Fleet Analytics resource from a Fleet.
"""

helps['cosmosdb softdeleted-account'] = """
type: group
short-summary: Manage soft-deleted Azure Cosmos DB accounts.
"""

helps['cosmosdb softdeleted-account list'] = """
type: command
short-summary: List soft-deleted Azure Cosmos DB accounts.
examples:
- name: List all soft-deleted Azure Cosmos DB accounts in a subscription.
text: |
az cosmosdb softdeleted-account list
- name: List soft-deleted Azure Cosmos DB accounts in a specific location.
text: |
az cosmosdb softdeleted-account list --location westus
"""

helps['cosmosdb softdeleted-account show'] = """
type: command
short-summary: Show details of a soft-deleted Azure Cosmos DB account.
examples:
- name: Show details of a soft-deleted Azure Cosmos DB account.
text: |
az cosmosdb softdeleted-account show --location westus --name MyAccount --resource-group MyResourceGroup
"""

helps['cosmosdb softdeleted-account delete'] = """
type: command
short-summary: Permanently delete a soft-deleted Azure Cosmos DB account.
examples:
- name: Permanently delete a soft-deleted Azure Cosmos DB account.
text: |
az cosmosdb softdeleted-account delete --location westus --name MyAccount --resource-group MyResourceGroup
"""

helps['cosmosdb softdeleted-account recover'] = """
type: command
short-summary: Recover a soft-deleted Azure Cosmos DB account.
examples:
- name: Recover a soft-deleted Azure Cosmos DB account.
text: |
az cosmosdb softdeleted-account recover --location westus --name MyAccount --resource-group MyResourceGroup
"""

helps['cosmosdb sql softdeleted-database'] = """
type: group
short-summary: Manage soft-deleted databases for Azure Cosmos DB SQL API.
"""

helps['cosmosdb sql softdeleted-database list'] = """
type: command
short-summary: List all soft-deleted databases for an Azure Cosmos DB account.
examples:
- name: List all soft-deleted databases for an Azure Cosmos DB account.
text: |
az cosmosdb sql softdeleted-database list --location westus --account-name MyAccount --resource-group MyResourceGroup
"""

helps['cosmosdb sql softdeleted-database show'] = """
type: command
short-summary: Show details of a soft-deleted database.
examples:
- name: Show details of a soft-deleted database.
text: |
az cosmosdb sql softdeleted-database show --location westus --account-name MyAccount --name MyDatabase --resource-group MyResourceGroup
"""

helps['cosmosdb sql softdeleted-database delete'] = """
type: command
short-summary: Permanently delete a soft-deleted database.
examples:
- name: Permanently delete a soft-deleted database.
text: |
az cosmosdb sql softdeleted-database delete --location westus --account-name MyAccount --name MyDatabase --resource-group MyResourceGroup
"""

helps['cosmosdb sql softdeleted-database recover'] = """
type: command
short-summary: Recover a soft-deleted database.
examples:
- name: Recover a soft-deleted database.
text: |
az cosmosdb sql softdeleted-database recover --location westus --account-name MyAccount --name MyDatabase --resource-group MyResourceGroup
"""

helps['cosmosdb sql softdeleted-container'] = """
type: group
short-summary: Manage soft-deleted containers for Azure Cosmos DB SQL API.
"""

helps['cosmosdb sql softdeleted-container list'] = """
type: command
short-summary: List all soft-deleted containers in a database.
examples:
- name: List all soft-deleted containers in a database.
text: |
az cosmosdb sql softdeleted-container list --location westus --account-name MyAccount --database-name MyDatabase --resource-group MyResourceGroup
"""

helps['cosmosdb sql softdeleted-container show'] = """
type: command
short-summary: Show details of a soft-deleted container.
examples:
- name: Show details of a soft-deleted container.
text: |
az cosmosdb sql softdeleted-container show --location westus --account-name MyAccount --database-name MyDatabase --name MyContainer --resource-group MyResourceGroup
"""

helps['cosmosdb sql softdeleted-container delete'] = """
type: command
short-summary: Permanently delete a soft-deleted container.
examples:
- name: Permanently delete a soft-deleted container.
text: |
az cosmosdb sql softdeleted-container delete --location westus --account-name MyAccount --database-name MyDatabase --name MyContainer --resource-group MyResourceGroup
"""

helps['cosmosdb sql softdeleted-container recover'] = """
type: command
short-summary: Recover a soft-deleted container.
examples:
- name: Recover a soft-deleted container.
text: |
az cosmosdb sql softdeleted-container recover --location westus --account-name MyAccount --database-name MyDatabase --name MyContainer --resource-group MyResourceGroup
"""
78 changes: 77 additions & 1 deletion src/cosmosdb-preview/azext_cosmosdb_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
validate_mongoMI_role_assignment_id,
validate_fleetspace_body,
validate_fleetspaceAccount_body,
validate_fleet_analytics_body)
validate_fleet_analytics_body,
validate_soft_delete_configuration)

from azext_cosmosdb_preview.actions import (
CreateGremlinDatabaseRestoreResource,
Expand Down Expand Up @@ -447,6 +448,7 @@ def load_arguments(self, _):
c.argument('gremlin_databases_to_restore', nargs='+', action=CreateGremlinDatabaseRestoreResource, is_preview=True, arg_group='Restore')
c.argument('tables_to_restore', nargs='+', action=CreateTableRestoreResource, is_preview=True, arg_group='Restore')
c.argument('enable_partition_merge', arg_type=get_three_state_flag(), is_preview=True, help="Flag to enable partition merge on the account.")
c.argument('disable_local_auth', arg_type=get_three_state_flag(), help="Flag to disable local authentication and ensure only MSI and AAD can be used exclusively for authentication.")

for scope in ['cosmosdb create', 'cosmosdb update']:
with self.argument_context(scope) as c:
Expand Down Expand Up @@ -486,6 +488,7 @@ def load_arguments(self, _):

with self.argument_context('cosmosdb update') as c:
c.argument('key_uri', help="The URI of the key vault", is_preview=True)
c.argument('soft_delete_configuration', options_list=['--soft-delete-config'], validator=validate_soft_delete_configuration, completer=FilesCompleter(), help="Soft delete configuration for the account, as a JSON string or a path to a JSON file, e.g. --soft-delete-config @soft-delete-config.json. Supported keys: softDeletionEnabled (bool), softDeleteRetentionPeriodInMinutes (int) and minMinutesBeforePermanentDeletionAllowed (int).", is_preview=True, arg_group='Soft Delete')

with self.argument_context('cosmosdb restore') as c:
c.argument('target_database_account_name', options_list=['--target-database-account-name', '-n'], help='Name of the new target Cosmos DB database account after the restore')
Expand All @@ -500,6 +503,7 @@ def load_arguments(self, _):
c.argument('public_network_access', options_list=['--public-network-access', '-p'], arg_type=get_enum_type(['ENABLED', 'DISABLED']), help="Sets public network access in server to either Enabled or Disabled.")
c.argument('source_backup_location', help="This is the location of the source account where backups are located. Provide this value if the source and target are in different locations.", is_preview=True)
c.argument('disable_ttl', options_list=['--disable-ttl'], arg_type=get_three_state_flag(), help="Enable or disable restoring with ttl disabled.", is_preview=True)
c.argument('disable_local_auth', arg_type=get_three_state_flag(), help="Flag to disable local authentication and ensure only MSI and AAD can be used exclusively for authentication.")

# Restorable Database Accounts
with self.argument_context('cosmosdb restorable-database-account show') as c:
Expand Down Expand Up @@ -829,6 +833,78 @@ def load_arguments(self, _):
c.argument('scope', options_list=['--scope', '-s'], help="Data plane resource path at which this Role Assignment is being granted.")
c.argument('principal_id', options_list=['--principal-id', '-p'], help="AAD Object ID of the principal to which this Role Assignment is being granted.")

# Soft-deleted Account
with self.argument_context('cosmosdb softdeleted-account list') as c:
c.argument('location', options_list=['--location', '-l'], help="Location of the soft-deleted accounts.", required=True)
c.argument('resource_group_name', options_list=['--resource-group', '-g'], help="Name of the resource group. If provided, lists only soft-deleted accounts in that resource group.", required=False)

with self.argument_context('cosmosdb softdeleted-account show') as c:
c.argument('location', options_list=['--location', '-l'], help="Location of the soft-deleted account.", required=True)
c.argument('account_name', options_list=['--name', '-n'], help="Name of the soft-deleted Cosmos DB account.", required=True)
c.argument('resource_group', options_list=['--resource-group', '-g'], help="Name of the resource group.", required=True)

with self.argument_context('cosmosdb softdeleted-account delete') as c:
c.argument('location', options_list=['--location', '-l'], help="Location of the soft-deleted account.", required=True)
c.argument('account_name', options_list=['--name', '-n'], help="Name of the soft-deleted Cosmos DB account to purge.", required=True)
c.argument('resource_group', options_list=['--resource-group', '-g'], help="Name of the resource group.", required=True)

with self.argument_context('cosmosdb softdeleted-account recover') as c:
c.argument('location', options_list=['--location', '-l'], help="Location of the soft-deleted account.", required=True)
c.argument('account_name', options_list=['--name', '-n'], help="Name of the soft-deleted Cosmos DB account to recover.", required=True)
c.argument('resource_group', options_list=['--resource-group', '-g'], help="Name of the resource group.", required=True)

# Soft-deleted Database
with self.argument_context('cosmosdb sql softdeleted-database list') as c:
c.argument('location', options_list=['--location', '-l'], help="Location of the account.", required=True)
c.argument('account_name', options_list=['--account-name', '-a'], help="Name of the Cosmos DB account.", required=True)
c.argument('resource_group', options_list=['--resource-group', '-g'], help="Name of the resource group.", required=True)

with self.argument_context('cosmosdb sql softdeleted-database show') as c:
c.argument('location', options_list=['--location', '-l'], help="Location of the account.", required=True)
c.argument('account_name', options_list=['--account-name', '-a'], help="Name of the Cosmos DB account.", required=True)
c.argument('database_name', options_list=['--name', '-n'], help="Name of the soft-deleted database.", required=True)
c.argument('resource_group', options_list=['--resource-group', '-g'], help="Name of the resource group.", required=True)

with self.argument_context('cosmosdb sql softdeleted-database delete') as c:
c.argument('location', options_list=['--location', '-l'], help="Location of the account.", required=True)
c.argument('account_name', options_list=['--account-name', '-a'], help="Name of the Cosmos DB account.", required=True)
c.argument('database_name', options_list=['--name', '-n'], help="Name of the soft-deleted database to purge.", required=True)
c.argument('resource_group', options_list=['--resource-group', '-g'], help="Name of the resource group.", required=True)

with self.argument_context('cosmosdb sql softdeleted-database recover') as c:
c.argument('location', options_list=['--location', '-l'], help="Location of the account.", required=True)
c.argument('account_name', options_list=['--account-name', '-a'], help="Name of the Cosmos DB account.", required=True)
c.argument('database_name', options_list=['--name', '-n'], help="Name of the soft-deleted database to recover.", required=True)
c.argument('resource_group', options_list=['--resource-group', '-g'], help="Name of the resource group.", required=True)

# Soft-deleted Collection
with self.argument_context('cosmosdb sql softdeleted-container list') as c:
c.argument('location', options_list=['--location', '-l'], help="Location of the account.", required=True)
c.argument('account_name', options_list=['--account-name', '-a'], help="Name of the Cosmos DB account.", required=True)
c.argument('database_name', options_list=['--database-name', '-d'], help="Name of the database.", required=True)
c.argument('resource_group', options_list=['--resource-group', '-g'], help="Name of the resource group.", required=True)

with self.argument_context('cosmosdb sql softdeleted-container show') as c:
c.argument('location', options_list=['--location', '-l'], help="Location of the account.", required=True)
c.argument('account_name', options_list=['--account-name', '-a'], help="Name of the Cosmos DB account.", required=True)
c.argument('database_name', options_list=['--database-name', '-d'], help="Name of the database.", required=True)
c.argument('container_name', options_list=['--name', '-n'], help="Name of the soft-deleted container.", required=True)
c.argument('resource_group', options_list=['--resource-group', '-g'], help="Name of the resource group.", required=True)

with self.argument_context('cosmosdb sql softdeleted-container delete') as c:
c.argument('location', options_list=['--location', '-l'], help="Location of the account.", required=True)
c.argument('account_name', options_list=['--account-name', '-a'], help="Name of the Cosmos DB account.", required=True)
c.argument('database_name', options_list=['--database-name', '-d'], help="Name of the database.", required=True)
c.argument('container_name', options_list=['--name', '-n'], help="Name of the soft-deleted container to purge.", required=True)
c.argument('resource_group', options_list=['--resource-group', '-g'], help="Name of the resource group.", required=True)

with self.argument_context('cosmosdb sql softdeleted-container recover') as c:
c.argument('location', options_list=['--location', '-l'], help="Location of the account.", required=True)
c.argument('account_name', options_list=['--account-name', '-a'], help="Name of the Cosmos DB account.", required=True)
c.argument('database_name', options_list=['--database-name', '-d'], help="Name of the database.", required=True)
c.argument('container_name', options_list=['--name', '-n'], help="Name of the soft-deleted container to recover.", required=True)
c.argument('resource_group', options_list=['--resource-group', '-g'], help="Name of the resource group.", required=True)

# Cosmos DB Fleet
with self.argument_context('cosmosdb fleet') as c:
c.argument('resource_group', options_list=['--resource-group', '-g'], help='Name of the resource group.', required=True)
Expand Down
Loading
Loading