Skip to content

[CosmosDB]Throughput bucket preview #27824

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
46e2861
Initial changes to support throughput bucketing
Achint-Agrawal May 12, 2025
917a99a
Add NewAzCosmosDBThroughputBucketObject cmdlet and PSThroughputBucket…
Achint-Agrawal May 12, 2025
399dd2b
Added test
Achint-Agrawal May 12, 2025
1dbe811
Update throughput bucket tests and remove obsolete function
Achint-Agrawal May 12, 2025
4d8eae7
Update throughput bucket parameters and help messages
Achint-Agrawal May 13, 2025
80fb3ec
Enhance throughput tests for Cosmos DB containers
Achint-Agrawal May 13, 2025
49b8812
Fix parameter names in Test-SqlThroughputCmdlets
Achint-Agrawal May 14, 2025
2391266
Update throughput settings to use PSThroughputBucket
Achint-Agrawal May 19, 2025
b69c38f
Revert changes to tests
Achint-Agrawal May 22, 2025
72580d2
Added test and recording
Achint-Agrawal May 22, 2025
d5a7eee
Updated changelog
Achint-Agrawal May 23, 2025
06ceaaa
Add New Cmdlet for CosmosDB Throughput Buckets
Achint-Agrawal May 23, 2025
31255f0
Update documentation for New-AzCosmosDBThroughputBucketObject
Achint-Agrawal May 26, 2025
78d4cef
Added missing constants
Achint-Agrawal May 30, 2025
a3fe38f
Rename ThroughputBuckets to ThroughputBucketsObject
Achint-Agrawal Jun 2, 2025
8d2eaa8
Rerecorded test
Achint-Agrawal Jun 2, 2025
20730c6
Updated help files - Update throughput parameter names in CosmosDB co…
Achint-Agrawal Jun 2, 2025
0b5bcaa
Update online version link in New-AzCosmosDBThroughputBucketObject he…
Achint-Agrawal Jun 3, 2025
e801e51
Added missing modules to Az.CosmosDB.psd1
pjohari-ms Jun 9, 2025
c44aff1
Merge pull request #1 from pjohari-ms/ThroughputBucketPreview
Achint-Agrawal Jun 9, 2025
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
7 changes: 4 additions & 3 deletions src/Accounts/Accounts/Utilities/CommandMappings.json
Original file line number Diff line number Diff line change
Expand Up @@ -1714,13 +1714,14 @@
"New-AzCosmosDBSqlUniqueKey": {},
"New-AzCosmosDBSqlUniqueKeyPolicy": {},
"New-AzCosmosDBSqlUserDefinedFunction": {},
"New-AzCosmosDBTable": {},
"New-AzCosmosDBTableRoleAssignment": {},
"New-AzCosmosDBTableRoleDefinition": {},
"New-AzCosmosDBSqlVectorEmbedding": {},
"New-AzCosmosDBSqlVectorEmbeddingPolicy": {},
"New-AzCosmosDBSqlVectorIndex": {},
"New-AzCosmosDBTable": {},
"New-AzCosmosDBTableRoleAssignment": {},
"New-AzCosmosDBTableRoleDefinition": {},
"New-AzCosmosDBTableToRestore": {},
"New-AzCosmosDBThroughputBucketObject": {},
"New-AzCosmosDBVirtualNetworkRule": {},
"New-AzManagedCassandraCluster": {},
"New-AzManagedCassandraDatacenter": {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ public void TestSqlThroughputCmdlets()
TestRunner.RunTestScript("Test-SqlThroughputCmdlets");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSqlThroughputBucketsCmdlets()
{
TestRunner.RunTestScript("Test-SqlThroughputBucketsCmdlets");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSqlMigrateThroughputCmdlets()
Expand Down
112 changes: 111 additions & 1 deletion src/CosmosDB/CosmosDB.Test/ScenarioTests/SqlOperationsTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2063,4 +2063,114 @@ function Test-SqlDatabaseMergeCmdlet
Remove-AzCosmosDBSqlContainer -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $ContainerName
Remove-AzCosmosDBSqlDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName
}
}
}

# This test requires subscription 074d02eb-4d74-486a-b299-b262264d1536 to run
<#
.SYNOPSIS
Tests SQL throughput buckets cmdlets
#>
function Test-SqlThroughputBucketsCmdlets
{
$AccountName = "throughput-bucketing-rp-test"
$rgName = "throughput-bucketing-rg"
$DatabaseName = "dbName3"
$ContainerName = "containerName"

$PartitionKeyPathValue = "/foo/bar"
$PartitionKeyKindValue = "Hash"

$ThroughputValue = 1200
$UpdatedThroughputValue = 1100
$UpdatedThroughputValue2 = 1000
$UpdatedThroughputValue3 = 900

$ContainerThroughputValue = 800
$UpdatedContainerThroughputValue = 700
$UpdatedContainerThroughputValue2 = 600
$UpdatedContainerThroughputValue3 = 500

$DatabaseName2 = "dbName4"
$ContainerName2 = "containerName3"
$AutoscaleContainerThroughput = 5000
$AutoscaleUpdatedContainerThroughput = 10000
$AutoscaleDatabaseThroughput = 8000
$AutoscaleUpdatedDatabaseThroughput = 12000
$location = "East US"
$apiKind = "Sql"
$consistencyLevel = "BoundedStaleness"
$locations = @()
$locations += New-AzCosmosDBLocationObject -LocationName "East Us" -FailoverPriority 0 -IsZoneRedundant 0

$ThroughputBucket1 = New-AzCosmosDBThroughputBucketObject -Id 1 -MaxThroughputPercentage 20
$ThroughputBucket2 = New-AzCosmosDBThroughputBucketObject -Id 2 -MaxThroughputPercentage 30

Try{
$NewDatabase = New-AzCosmosDBSqlDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName -Throughput $ThroughputValue
$Throughput = Get-AzCosmosDBSqlDatabaseThroughput -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName
Assert-AreEqual $Throughput.Throughput $ThroughputValue

$UpdatedThroughput = Update-AzCosmosDBSqlDatabaseThroughput -InputObject $NewDatabase -Throughput $UpdatedThroughputValue
Assert-AreEqual $UpdatedThroughput.Throughput $UpdatedThroughputValue

$UpdatedThroughput = Update-AzCosmosDBSqlDatabaseThroughput -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName -Throughput $UpdatedThroughputValue2
Assert-AreEqual $UpdatedThroughput.Throughput $UpdatedThroughputValue2

$CosmosDBAccount = Get-AzCosmosDBAccount -ResourceGroupName $rgName -Name $AccountName
$UpdatedThroughput = Update-AzCosmosDBSqlDatabaseThroughput -ParentObject $CosmosDBAccount -Name $DatabaseName -Throughput $UpdatedThroughputValue3
Assert-AreEqual $UpdatedThroughput.Throughput $UpdatedThroughputValue3

$NewContainer = New-AzCosmosDBSqlContainer -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Throughput $ContainerThroughputValue -Name $ContainerName -PartitionKeyPath $PartitionKeyPathValue -PartitionKeyKind $PartitionKeyKindValue
$ContainerThroughput = Get-AzCosmosDBSqlContainerThroughput -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $ContainerName
Assert-AreEqual $ContainerThroughput.Throughput $ContainerThroughputValue

$UpdatedContainerThroughput = Update-AzCosmosDBSqlContainerThroughput -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $ContainerName -Throughput $UpdatedContainerThroughputValue
Assert-AreEqual $UpdatedContainerThroughput.Throughput $UpdatedContainerThroughputValue

$UpdatedContainerThroughput = Update-AzCosmosDBSqlContainerThroughput -InputObject $NewContainer -Throughput $UpdatedContainerThroughputValue2
Assert-AreEqual $UpdatedContainerThroughput.Throughput $UpdatedContainerThroughputValue2

$UpdatedContainerThroughput = Update-AzCosmosDBSqlContainerThroughput -ParentObject $NewDatabase -Name $ContainerName -Throughput $UpdatedContainerThroughputValue3
Assert-AreEqual $UpdatedContainerThroughput.Throughput $UpdatedContainerThroughputValue3

# Throughput bucketing scenario
$UpdatedContainerThroughput = Update-AzCosmosDBSqlContainerThroughput -ResourceGroupName $rgName -AccountName $AccountName -DatabaseName $DatabaseName -Name $ContainerName -Throughput $ContainerThroughputValue -ThroughputBucketsObject @($ThroughputBucket1, $ThroughputBucket2)
Assert-AreEqual $UpdatedContainerThroughput.Throughput $ContainerThroughputValue
Assert-AreEqual $UpdatedContainerThroughput.ThroughputBucketsObject.Count 2
Assert-AreEqual $UpdatedContainerThroughput.ThroughputBucketsObject[0].Id 1
Assert-AreEqual $UpdatedContainerThroughput.ThroughputBucketsObject[0].MaxThroughputPercentage 20
Assert-AreEqual $UpdatedContainerThroughput.ThroughputBucketsObject[1].Id 2
Assert-AreEqual $UpdatedContainerThroughput.ThroughputBucketsObject[1].MaxThroughputPercentage 30

$UpdatedContainerThroughput = Update-AzCosmosDBSqlContainerThroughput -ResourceGroupName $rgName -AccountName $AccountName -DatabaseName $DatabaseName -Name $ContainerName -Throughput $ContainerThroughputValue -ThroughputBucketsObject @()
Assert-AreEqual $UpdatedContainerThroughput.Throughput $ContainerThroughputValue
Assert-AreEqual $UpdatedContainerThroughput.ThroughputBucketsObject.Count 0

# autoscale scenarios
$AutoscaleDatabase = New-AzCosmosDBSqlDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName2 -AutoscaleMaxThroughput $AutoscaleDatabaseThroughput
$Throughput = Get-AzCosmosDBSqlDatabaseThroughput -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName2
Assert-AreEqual $Throughput.AutoscaleSettings.MaxThroughput $AutoscaleDatabaseThroughput

$AutoscaleContainer = New-AzCosmosDBSqlContainer -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName2 -AutoscaleMaxThroughput $AutoscaleContainerThroughput -Name $ContainerName2 -PartitionKeyPath $PartitionKeyPathValue -PartitionKeyKind $PartitionKeyKindValue
$ContainerThroughput = Get-AzCosmosDBSqlContainerThroughput -InputObject $AutoscaleContainer
Assert-AreEqual $ContainerThroughput.AutoscaleSettings.MaxThroughput $AutoscaleContainerThroughput

$UpdatedContainerThroughput = Update-AzCosmosDBSqlContainerThroughput -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName2 -Name $ContainerName2 -AutoscaleMaxThroughput $AutoscaleUpdatedContainerThroughput
Assert-AreEqual $UpdatedContainerThroughput.AutoscaleSettings.MaxThroughput $AutoscaleUpdatedContainerThroughput

# can only update throughput of database if it has atleast one container with shared throughput
# $UpdatedThroughput = Update-AzCosmosDBSqlDatabaseThroughput -InputObject $AutoscaleDatabase -AutoscaleMaxThroughput $AutoscaleUpdatedDatabaseThroughput
# Assert-AreEqual $UpdatedThroughput.AutoscaleSettings.MaxThroughput $AutoscaleUpdatedDatabaseThroughput

Remove-AzCosmosDBSqlContainer -InputObject $NewContainer
Remove-AzCosmosDBSqlDatabase -InputObject $NewDatabase
Remove-AzCosmosDBSqlContainer -InputObject $AutoscaleContainer
Remove-AzCosmosDBSqlDatabase -InputObject $AutoscaleDatabase
}
Finally{
Remove-AzCosmosDBSqlContainer -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $ContainerName
Remove-AzCosmosDBSqlDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName
Remove-AzCosmosDBSqlContainer -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName2 -Name $ContainerName2
Remove-AzCosmosDBSqlDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName2
}
}
Loading
Loading