From 61fe310959c973e0cfc53afa92258d4140186bf2 Mon Sep 17 00:00:00 2001 From: Praful Johari Date: Mon, 14 Sep 2026 18:58:28 -0500 Subject: [PATCH 1/3] Cosmos DB: add per-partition automatic failover --- .../cli/command_modules/cosmosdb/_help.py | 14 ++++++++ .../cli/command_modules/cosmosdb/_params.py | 1 + .../cli/command_modules/cosmosdb/custom.py | 6 ++++ .../latest/test_cosmosdb-ppaf-scenario.py | 35 +++++++++++++++++++ 4 files changed, 56 insertions(+) create mode 100644 src/azure-cli/azure/cli/command_modules/cosmosdb/tests/latest/test_cosmosdb-ppaf-scenario.py diff --git a/src/azure-cli/azure/cli/command_modules/cosmosdb/_help.py b/src/azure-cli/azure/cli/command_modules/cosmosdb/_help.py index 003ae121e7b..6b4299e3de0 100644 --- a/src/azure-cli/azure/cli/command_modules/cosmosdb/_help.py +++ b/src/azure-cli/azure/cli/command_modules/cosmosdb/_help.py @@ -193,6 +193,11 @@ Usage: --enable-burst-capacity true Default: false The accepted values for the enable-burst-capacity are true and false. + - name: --enable-per-partition-automatic-failover + short-summary: Enable per-partition automatic failover for the account. + long-summary: | + Usage: --enable-per-partition-automatic-failover true + The accepted values are true and false. - name: --enable-prpp-autoscale short-summary: Flag to Enable/Disable burst capacity feature long-summary: | @@ -205,6 +210,8 @@ crafted: true - name: Creates a new Azure Cosmos DB database account with two regions. UK South is zone redundant. text: az cosmosdb create -n myaccount -g mygroup --locations regionName=eastus failoverPriority=0 isZoneRedundant=False --locations regionName=uksouth failoverPriority=1 isZoneRedundant=True --enable-multiple-write-locations --network-acl-bypass AzureServices --network-acl-bypass-resource-ids /subscriptions/subId/resourceGroups/rgName/providers/Microsoft.Synapse/workspaces/wsName + - name: Create an account with per-partition automatic failover enabled. + text: az cosmosdb create -n myaccount -g mygroup --locations regionName=southcentralus failoverPriority=0 --locations regionName=eastus failoverPriority=1 --enable-per-partition-automatic-failover true - name: Create a new Azure Cosmos DB database account by restoring from an existing account in the given location text: az cosmosdb create -n restoredaccount -g mygroup --is-restore-request true --restore-source /subscriptions/2296c272-5d55-40d9-bc05-4d56dc2d7588/providers/Microsoft.DocumentDB/locations/westus/restorableDatabaseAccounts/d056a4f8-044a-436f-80c8-cd3edbc94c68 --restore-timestamp 2020-07-13T16:03:41+0000 --locations regionName=westus failoverPriority=0 isZoneRedundant=False """ @@ -972,6 +979,11 @@ Usage: --enable-burst-capacity true Default: false The accepted values for the enable-burst-capacity are true and false. + - name: --enable-per-partition-automatic-failover + short-summary: Enable per-partition automatic failover for the account. + long-summary: | + Usage: --enable-per-partition-automatic-failover true + The accepted values are true and false. - name: --enable-prpp-autoscale short-summary: Flag to Enable/Disable burst capacity feature long-summary: | @@ -984,6 +996,8 @@ crafted: true - name: Creates a new Azure Cosmos DB database account with two regions. UK South is zone redundant. text: az cosmosdb update -n myaccount -g mygroup --locations regionName=eastus failoverPriority=0 isZoneRedundant=False --locations regionName=uksouth failoverPriority=1 isZoneRedundant=True --enable-multiple-write-locations --network-acl-bypass AzureServices --network-acl-bypass-resource-ids /subscriptions/subId/resourceGroups/rgName/providers/Microsoft.Synapse/workspaces/wsName + - name: Enable per-partition automatic failover on an account. + text: az cosmosdb update -n myaccount -g mygroup --enable-per-partition-automatic-failover true """ helps['cosmosdb mongodb role'] = """ diff --git a/src/azure-cli/azure/cli/command_modules/cosmosdb/_params.py b/src/azure-cli/azure/cli/command_modules/cosmosdb/_params.py index 3d61ca6d8f5..110376d7b8a 100644 --- a/src/azure-cli/azure/cli/command_modules/cosmosdb/_params.py +++ b/src/azure-cli/azure/cli/command_modules/cosmosdb/_params.py @@ -155,6 +155,7 @@ def load_arguments(self, _): c.argument('backup_policy_type', arg_type=get_enum_type(BackupPolicyType), help="The type of backup policy of the account to create", arg_group='Backup Policy') c.argument('enable_partition_merge', arg_type=get_three_state_flag(), help="Flag to enable partition merge on the account.") c.argument('enable_burst_capacity', arg_type=get_three_state_flag(), help="Flag to enable burst capacity on the account.") + c.argument('enable_per_partition_automatic_failover', arg_type=get_three_state_flag(), help="Flag to enable per-partition automatic failover on the account.") c.argument('enable_prpp_autoscale', arg_type=get_three_state_flag(), help="Enable or disable PerRegionPerPartitionAutoscale.") c.argument('enable_pbe', arg_type=get_three_state_flag(), help="Flag to enable priority based execution on the account.") c.argument('default_priority_level', arg_type=get_enum_type(DefaultPriorityLevel), help="Default Priority Level of Request if not specified.") diff --git a/src/azure-cli/azure/cli/command_modules/cosmosdb/custom.py b/src/azure-cli/azure/cli/command_modules/cosmosdb/custom.py index 466842c2698..7be4ca72778 100644 --- a/src/azure-cli/azure/cli/command_modules/cosmosdb/custom.py +++ b/src/azure-cli/azure/cli/command_modules/cosmosdb/custom.py @@ -151,6 +151,7 @@ def cli_cosmosdb_create(cmd, restore_timestamp=None, enable_partition_merge=None, enable_burst_capacity=None, + enable_per_partition_automatic_failover=None, enable_prpp_autoscale=None, minimal_tls_version=None, enable_pbe=None, @@ -210,6 +211,7 @@ def cli_cosmosdb_create(cmd, arm_location=resource_group_location, enable_partition_merge=enable_partition_merge, enable_burst_capacity=enable_burst_capacity, + enable_per_partition_automatic_failover=enable_per_partition_automatic_failover, enable_prpp_autoscale=enable_prpp_autoscale, minimal_tls_version=minimal_tls_version, enable_pbe=enable_pbe, @@ -259,6 +261,7 @@ def _create_database_account(client, arm_location=None, enable_partition_merge=None, enable_burst_capacity=None, + enable_per_partition_automatic_failover=None, enable_prpp_autoscale=None, minimal_tls_version=None, disable_ttl=None, @@ -421,6 +424,7 @@ def _create_database_account(client, restore_parameters=restore_parameters, enable_partition_merge=enable_partition_merge, enable_burst_capacity=enable_burst_capacity, + per_partition_automatic_failover_enabled=enable_per_partition_automatic_failover, enable_per_region_per_partition_autoscale=enable_prpp_autoscale, minimal_tls_version=minimal_tls_version, enable_priority_based_execution=enable_pbe, @@ -479,6 +483,7 @@ def cli_cosmosdb_update(client, continuous_tier=None, enable_partition_merge=None, enable_burst_capacity=None, + enable_per_partition_automatic_failover=None, enable_prpp_autoscale=None, minimal_tls_version=None, enable_pbe=None, @@ -580,6 +585,7 @@ def cli_cosmosdb_update(client, analytical_storage_configuration=analytical_storage_configuration, enable_partition_merge=enable_partition_merge, enable_burst_capacity=enable_burst_capacity, + per_partition_automatic_failover_enabled=enable_per_partition_automatic_failover, enable_per_region_per_partition_autoscale=enable_prpp_autoscale, minimal_tls_version=minimal_tls_version, enable_priority_based_execution=enable_pbe, diff --git a/src/azure-cli/azure/cli/command_modules/cosmosdb/tests/latest/test_cosmosdb-ppaf-scenario.py b/src/azure-cli/azure/cli/command_modules/cosmosdb/tests/latest/test_cosmosdb-ppaf-scenario.py new file mode 100644 index 00000000000..56b20cb2543 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/cosmosdb/tests/latest/test_cosmosdb-ppaf-scenario.py @@ -0,0 +1,35 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +from azure.cli.testsdk import ScenarioTest, ResourceGroupPreparer +from azure.cli.testsdk.scenario_tests import AllowLargeResponse + + +class CosmosdbPerPartitionAutomaticFailoverScenarioTest(ScenarioTest): + + @AllowLargeResponse() + @ResourceGroupPreparer(name_prefix='cli_test_cosmosdb_ppaf', location='southcentralus') + def test_cosmosdb_per_partition_automatic_failover(self, resource_group): + self.kwargs.update({ + 'acc': self.create_random_name(prefix='ppaf-test-', length=20) + }) + + self.cmd( + 'az cosmosdb create -n {acc} -g {rg} ' + '--locations regionName=southcentralus failoverPriority=0 ' + '--locations regionName=eastus failoverPriority=1 ' + '--enable-per-partition-automatic-failover true') + self.cmd('az cosmosdb show -n {acc} -g {rg}', checks=[ + self.check('perPartitionAutomaticFailoverEnabled', True), + ]) + + self.cmd( + 'az cosmosdb update -n {acc} -g {rg} ' + '--enable-per-partition-automatic-failover true') + self.cmd('az cosmosdb show -n {acc} -g {rg}', checks=[ + self.check('perPartitionAutomaticFailoverEnabled', True), + ]) + + self.cmd('az cosmosdb delete -n {acc} -g {rg} --yes') \ No newline at end of file From 7a5436051465b3d649e4f91c904417e074867172 Mon Sep 17 00:00:00 2001 From: Praful Johari Date: Mon, 14 Sep 2026 19:03:42 -0500 Subject: [PATCH 2/3] Cosmos DB: add backup retention lock support --- .../cli/command_modules/cosmosdb/_help.py | 14 ++++++ .../cli/command_modules/cosmosdb/_params.py | 1 + .../cli/command_modules/cosmosdb/custom.py | 18 ++++++++ .../test_cosmosdb-retention-lock-scenario.py | 45 +++++++++++++++++++ 4 files changed, 78 insertions(+) create mode 100644 src/azure-cli/azure/cli/command_modules/cosmosdb/tests/latest/test_cosmosdb-retention-lock-scenario.py diff --git a/src/azure-cli/azure/cli/command_modules/cosmosdb/_help.py b/src/azure-cli/azure/cli/command_modules/cosmosdb/_help.py index 6b4299e3de0..0c963512f23 100644 --- a/src/azure-cli/azure/cli/command_modules/cosmosdb/_help.py +++ b/src/azure-cli/azure/cli/command_modules/cosmosdb/_help.py @@ -180,6 +180,11 @@ short-summary: Add table names to restore long-summary: | Usage: --tables-to-restore tables=table1 [table2 ...] + - name: --backup-retention-lock-expiration-timestamp + short-summary: Set the retention lock expiration timestamp for continuous mode backups. + long-summary: | + Usage: --backup-retention-lock-expiration-timestamp 2030-01-01T00:00:00Z + This option can only be used with a continuous backup policy. - name: --minimal-tls-version short-summary: Indicate the minimum allowed TLS version long-summary: | @@ -214,6 +219,8 @@ text: az cosmosdb create -n myaccount -g mygroup --locations regionName=southcentralus failoverPriority=0 --locations regionName=eastus failoverPriority=1 --enable-per-partition-automatic-failover true - name: Create a new Azure Cosmos DB database account by restoring from an existing account in the given location text: az cosmosdb create -n restoredaccount -g mygroup --is-restore-request true --restore-source /subscriptions/2296c272-5d55-40d9-bc05-4d56dc2d7588/providers/Microsoft.DocumentDB/locations/westus/restorableDatabaseAccounts/d056a4f8-044a-436f-80c8-cd3edbc94c68 --restore-timestamp 2020-07-13T16:03:41+0000 --locations regionName=westus failoverPriority=0 isZoneRedundant=False + - name: Create an account with a continuous backup retention lock. + text: az cosmosdb create -n myaccount -g mygroup --backup-policy-type Continuous --backup-retention-lock-expiration-timestamp 2030-01-01T00:00:00Z """ helps['cosmosdb restore'] = """ @@ -966,6 +973,11 @@ Default: single region account in the location of the specified resource group. Failover priority values are 0 for write regions and greater than 0 for read regions. A failover priority value must be unique and less than the total number of regions. Multiple locations can be specified by using more than one `--locations` argument. + - name: --backup-retention-lock-expiration-timestamp + short-summary: Push forward the retention lock expiration timestamp for continuous mode backups. + long-summary: | + Usage: --backup-retention-lock-expiration-timestamp 2030-06-01T00:00:00Z + This option can only be used with a continuous backup policy. - name: --minimal-tls-version short-summary: Indicate the minimum allowed TLS version long-summary: | @@ -998,6 +1010,8 @@ text: az cosmosdb update -n myaccount -g mygroup --locations regionName=eastus failoverPriority=0 isZoneRedundant=False --locations regionName=uksouth failoverPriority=1 isZoneRedundant=True --enable-multiple-write-locations --network-acl-bypass AzureServices --network-acl-bypass-resource-ids /subscriptions/subId/resourceGroups/rgName/providers/Microsoft.Synapse/workspaces/wsName - name: Enable per-partition automatic failover on an account. text: az cosmosdb update -n myaccount -g mygroup --enable-per-partition-automatic-failover true + - name: Push forward a continuous backup retention lock. + text: az cosmosdb update -n myaccount -g mygroup --backup-retention-lock-expiration-timestamp 2030-06-01T00:00:00Z """ helps['cosmosdb mongodb role'] = """ diff --git a/src/azure-cli/azure/cli/command_modules/cosmosdb/_params.py b/src/azure-cli/azure/cli/command_modules/cosmosdb/_params.py index 110376d7b8a..dfe356eaffe 100644 --- a/src/azure-cli/azure/cli/command_modules/cosmosdb/_params.py +++ b/src/azure-cli/azure/cli/command_modules/cosmosdb/_params.py @@ -148,6 +148,7 @@ def load_arguments(self, _): c.argument('network_acl_bypass_resource_ids', nargs='+', options_list=['--network-acl-bypass-resource-ids', '-i'], help="List of Resource Ids to allow Network Acl Bypass.") c.argument('backup_interval', type=int, help="the frequency(in minutes) with which backups are taken (only for accounts with periodic mode backups)", arg_group='Backup Policy') c.argument('backup_retention', type=int, help="the time(in hours) for which each backup is retained (only for accounts with periodic mode backups)", arg_group='Backup Policy') + c.argument('backup_retention_lock_expiration_timestamp', action=UtcDatetimeAction, help="The retention lock expiration timestamp for continuous mode backups.", arg_group='Backup Policy') c.argument('backup_redundancy', arg_type=get_enum_type(BackupStorageRedundancy), help="The redundancy type of the backup Storage account", arg_group='Backup Policy') c.argument('server_version', arg_type=get_enum_type(ServerVersion), help="Valid only for MongoDB accounts.") c.argument('default_identity', help="The primary identity to access key vault in CMK related features. e.g. 'FirstPartyIdentity', 'SystemAssignedIdentity' and more. User-assigned identities are specified in format `UserAssignedIdentity=`.") diff --git a/src/azure-cli/azure/cli/command_modules/cosmosdb/custom.py b/src/azure-cli/azure/cli/command_modules/cosmosdb/custom.py index 7be4ca72778..e284b6870dd 100644 --- a/src/azure-cli/azure/cli/command_modules/cosmosdb/custom.py +++ b/src/azure-cli/azure/cli/command_modules/cosmosdb/custom.py @@ -137,6 +137,7 @@ def cli_cosmosdb_create(cmd, network_acl_bypass_resource_ids=None, backup_interval=None, backup_retention=None, + backup_retention_lock_expiration_timestamp=None, backup_redundancy=None, assign_identity=None, default_identity=None, @@ -205,6 +206,7 @@ def cli_cosmosdb_create(cmd, assign_identity=assign_identity, default_identity=default_identity, backup_retention=backup_retention, + backup_retention_lock_expiration_timestamp=backup_retention_lock_expiration_timestamp, databases_to_restore=databases_to_restore, gremlin_databases_to_restore=gremlin_databases_to_restore, tables_to_restore=tables_to_restore, @@ -246,6 +248,7 @@ def _create_database_account(client, network_acl_bypass_resource_ids=None, backup_interval=None, backup_retention=None, + backup_retention_lock_expiration_timestamp=None, backup_redundancy=None, assign_identity=None, default_identity=None, @@ -362,6 +365,12 @@ def _create_database_account(client, ) backup_policy.periodic_mode_properties = periodic_mode_properties + if backup_retention_lock_expiration_timestamp is not None: + if not isinstance(backup_policy, ContinuousModeBackupPolicy): + raise CLIError( + '--backup-retention-lock-expiration-timestamp can only be set with continuous backup policy.') + backup_policy.backup_retention_lock_expiration_timestamp = backup_retention_lock_expiration_timestamp + analytical_storage_configuration = None if analytical_storage_schema_type is not None: analytical_storage_configuration = AnalyticalStorageConfiguration() @@ -476,6 +485,7 @@ def cli_cosmosdb_update(client, server_version=None, backup_interval=None, backup_retention=None, + backup_retention_lock_expiration_timestamp=None, backup_redundancy=None, default_identity=None, analytical_storage_schema_type=None, @@ -557,6 +567,14 @@ def cli_cosmosdb_update(client, ) backup_policy.continuous_mode_properties = continuous_mode_properties + if backup_retention_lock_expiration_timestamp is not None: + if backup_policy is None: + backup_policy = existing.backup_policy + if not isinstance(backup_policy, ContinuousModeBackupPolicy): + raise CLIError( + '--backup-retention-lock-expiration-timestamp can only be set with continuous backup policy.') + backup_policy.backup_retention_lock_expiration_timestamp = backup_retention_lock_expiration_timestamp + analytical_storage_configuration = None if analytical_storage_schema_type is not None: analytical_storage_configuration = AnalyticalStorageConfiguration() diff --git a/src/azure-cli/azure/cli/command_modules/cosmosdb/tests/latest/test_cosmosdb-retention-lock-scenario.py b/src/azure-cli/azure/cli/command_modules/cosmosdb/tests/latest/test_cosmosdb-retention-lock-scenario.py new file mode 100644 index 00000000000..f76f43b65ca --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/cosmosdb/tests/latest/test_cosmosdb-retention-lock-scenario.py @@ -0,0 +1,45 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +from azure.cli.testsdk import ScenarioTest, ResourceGroupPreparer +from azure.cli.testsdk.scenario_tests import AllowLargeResponse + + +class CosmosdbRetentionLockScenarioTest(ScenarioTest): + + @AllowLargeResponse() + @ResourceGroupPreparer(name_prefix='cli_test_cosmosdb_retention_lock') + def test_cosmosdb_retention_lock(self, resource_group): + self.kwargs.update({ + 'acc': self.create_random_name(prefix='retention-lock-', length=25), + 'create_timestamp': '2030-01-01T00:00:00Z', + 'update_timestamp': '2030-06-01T00:00:00Z' + }) + + self.cmd( + 'az cosmosdb create -n {acc} -g {rg} ' + '--backup-policy-type Continuous ' + '--backup-retention-lock-expiration-timestamp {create_timestamp}', + checks=[ + self.check('backupPolicy.type', 'Continuous'), + self.check('backupPolicy.backupRetentionLockExpirationTimestamp', '{create_timestamp}'), + ]) + self.cmd('az cosmosdb show -n {acc} -g {rg}', checks=[ + self.check('backupPolicy.backupRetentionLockExpirationTimestamp', '{create_timestamp}'), + ]) + + self.cmd( + 'az cosmosdb update -n {acc} -g {rg} ' + '--backup-retention-lock-expiration-timestamp {update_timestamp}', + checks=[ + self.check('backupPolicy.backupRetentionLockExpirationTimestamp', '{update_timestamp}'), + ]) + + self.cmd('az cosmosdb update -n {acc} -g {rg} --tags retention-lock=preserved') + self.cmd('az cosmosdb show -n {acc} -g {rg}', checks=[ + self.check('backupPolicy.backupRetentionLockExpirationTimestamp', '{update_timestamp}'), + ]) + + self.cmd('az cosmosdb delete -n {acc} -g {rg} --yes') \ No newline at end of file From 2fb559fc804de7e80958d0e5da4f465d7ac220a1 Mon Sep 17 00:00:00 2001 From: Praful Johari Date: Mon, 14 Sep 2026 19:10:43 -0500 Subject: [PATCH 3/3] Cosmos DB: cover throughput buckets on stable API --- .../cli/command_modules/cosmosdb/_help.py | 6 ++ ...st_cosmosdb-throughput-buckets-scenario.py | 69 +++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 src/azure-cli/azure/cli/command_modules/cosmosdb/tests/latest/test_cosmosdb-throughput-buckets-scenario.py diff --git a/src/azure-cli/azure/cli/command_modules/cosmosdb/_help.py b/src/azure-cli/azure/cli/command_modules/cosmosdb/_help.py index 0c963512f23..d99a177a318 100644 --- a/src/azure-cli/azure/cli/command_modules/cosmosdb/_help.py +++ b/src/azure-cli/azure/cli/command_modules/cosmosdb/_help.py @@ -849,11 +849,17 @@ helps['cosmosdb sql container throughput show'] = """ type: command short-summary: Get the throughput of the SQL container under an Azure Cosmos DB SQL database. +examples: + - name: Show container throughput settings, including throughput buckets when configured. + text: az cosmosdb sql container throughput show -g mygroup -a myaccount -d mydatabase -n mycontainer """ helps['cosmosdb sql container throughput update'] = """ type: command short-summary: Update the throughput of the SQL container under an Azure Cosmos DB SQL database. +examples: + - name: Update container throughput while preserving configured throughput buckets. + text: az cosmosdb sql container throughput update -g mygroup -a myaccount -d mydatabase -n mycontainer --throughput 400 """ helps['cosmosdb sql container throughput migrate'] = """ diff --git a/src/azure-cli/azure/cli/command_modules/cosmosdb/tests/latest/test_cosmosdb-throughput-buckets-scenario.py b/src/azure-cli/azure/cli/command_modules/cosmosdb/tests/latest/test_cosmosdb-throughput-buckets-scenario.py new file mode 100644 index 00000000000..1edd4e68f2f --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/cosmosdb/tests/latest/test_cosmosdb-throughput-buckets-scenario.py @@ -0,0 +1,69 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +import json + +from azure.cli.testsdk import ScenarioTest, ResourceGroupPreparer + + +class CosmosdbThroughputBucketsScenarioTest(ScenarioTest): + + @ResourceGroupPreparer(name_prefix='cli_test_cosmosdb_throughput_buckets') + def test_cosmosdb_throughput_buckets_stable_api(self, resource_group): + subscription_id = self.get_subscription_id() + throughput_body = { + 'properties': { + 'resource': { + 'throughput': 400, + 'throughputBuckets': [ + {'id': 1, 'maxThroughputPercentage': 10, 'isDefaultBucket': True}, + {'id': 2, 'maxThroughputPercentage': 20, 'isDefaultBucket': False}, + {'id': 3, 'maxThroughputPercentage': 15} + ] + } + } + } + self.kwargs.update({ + 'acc': self.create_random_name(prefix='buckets-', length=20), + 'db_name': self.create_random_name(prefix='database-', length=20), + 'ctn_name': self.create_random_name(prefix='container-', length=20), + 'subscription_id': subscription_id, + 'throughput_body': json.dumps(throughput_body, separators=(',', ':')) + }) + + self.cmd('az cosmosdb create -n {acc} -g {rg}') + self.cmd('az cosmosdb sql database create -g {rg} -a {acc} -n {db_name}') + self.cmd( + 'az cosmosdb sql container create -g {rg} -a {acc} -d {db_name} ' + '-n {ctn_name} -p /partitionKey --throughput 400') + + throughput_url = ( + '/subscriptions/{subscription_id}/resourceGroups/{rg}/providers/Microsoft.DocumentDB/' + 'databaseAccounts/{acc}/sqlDatabases/{db_name}/containers/{ctn_name}/' + 'throughputSettings/default?api-version=2026-07-15') + self.cmd( + "az rest --method put --url '" + throughput_url + "' " + "--body '{throughput_body}'") + + bucket_checks = [ + self.check('resource.throughputBuckets[0].id', 1), + self.check('resource.throughputBuckets[0].maxThroughputPercentage', 10), + self.check('resource.throughputBuckets[0].isDefaultBucket', True), + self.check('resource.throughputBuckets[1].id', 2), + self.check('resource.throughputBuckets[1].maxThroughputPercentage', 20), + self.check('resource.throughputBuckets[1].isDefaultBucket', False), + self.check('resource.throughputBuckets[2].id', 3), + self.check('resource.throughputBuckets[2].maxThroughputPercentage', 15) + ] + self.cmd( + 'az cosmosdb sql container throughput show -g {rg} -a {acc} ' + '-d {db_name} -n {ctn_name}', + checks=bucket_checks) + self.cmd( + 'az cosmosdb sql container throughput update -g {rg} -a {acc} ' + '-d {db_name} -n {ctn_name} --throughput 400', + checks=bucket_checks) + + self.cmd('az cosmosdb delete -n {acc} -g {rg} --yes') \ No newline at end of file