Operasi throughput (RU/s) dengan PowerShell untuk keyspace atau tabel untuk Azure Cosmos DB - API untuk Cassandra
BERLAKU UNTUK: Cassandra
Catatan
Sebaiknya Anda menggunakan modul Azure Az PowerShell untuk berinteraksi dengan Azure. Untuk memulai, lihat Menginstal Azure PowerShell. Untuk mempelajari cara bermigrasi ke modul Az PowerShell, lihat Memigrasikan Azure PowerShell dari AzureRM ke Az.
Sampel ini memerlukan Azure PowerShell Az 5.4.0 atau yang lebih baru. Jalankan Get-Module -ListAvailable Az
untuk melihat versi mana yang dipasang.
Jika Anda perlu memasang, lihat Pasang modul Azure PowerShell.
Jalankan Connect-AzAccount untuk masuk ke Azure.
Mendapatkan throughput
# Reference: Az.CosmosDB | https://docs.microsoft.com/powershell/module/az.cosmosdb
# --------------------------------------------------
# Purpose
# Get keyspace or table throughput
# --------------------------------------------------
# Variables - ***** SUBSTITUTE YOUR VALUES *****
$resourceGroupName = "myResourceGroup" # Resource Group must already exist
$accountName = "myaccount" # Must be all lower case
$keyspaceName = "mykeyspace" # Keyspace with shared throughput
$tableName = "mytable" # Table with dedicated throughput
# --------------------------------------------------
Write-Host "Get keyspace shared throughput"
Get-AzCosmosDBCassandraKeyspaceThroughput -ResourceGroupName $resourceGroupName `
-AccountName $accountName -Name $keyspaceName
Write-Host "Get table dedicated throughput"
Get-AzCosmosDBCassandraTableThroughput -ResourceGroupName $resourceGroupName `
-AccountName $accountName -KeyspaceName $keyspaceName `
-Name $tableName
Perbarui throughput
# Reference: Az.CosmosDB | https://docs.microsoft.com/powershell/module/az.cosmosdb
# --------------------------------------------------
# Purpose
# Update table throughput
# --------------------------------------------------
# Variables - ***** SUBSTITUTE YOUR VALUES *****
$resourceGroupName = "myResourceGroup" # Resource Group must already exist
$accountName = "myaccount" # Must be all lower case
$keyspaceName = "mykeyspace"
$tableName = "mytable"
$newRUs = 500
# --------------------------------------------------
$throughput = Get-AzCosmosDBCassandraTableThroughput -ResourceGroupName $resourceGroupName `
-AccountName $accountName -KeyspaceName $keyspaceName -Name $tableName
$currentRUs = $throughput.Throughput
$minimumRUs = $throughput.MinimumThroughput
Write-Host "Current throughput is $currentRUs. Minimum allowed throughput is $minimumRUs."
if ([int]$newRUs -lt [int]$minimumRUs) {
Write-Host "Requested new throughput of $newRUs is less than minimum allowed throughput of $minimumRUs."
Write-Host "Using minimum allowed throughput of $minimumRUs instead."
$newRUs = $minimumRUs
}
if ([int]$newRUs -eq [int]$currentRUs) {
Write-Host "New throughput is the same as current throughput. No change needed."
}
else {
Write-Host "Updating throughput to $newRUs."
Update-AzCosmosDBCassandraTableThroughput -ResourceGroupName $resourceGroupName `
-AccountName $accountName -KeyspaceName $keyspaceName `
-Name $tableName -Throughput $newRUs
}
Migrasikan throughput
# Reference: Az.CosmosDB | https://docs.microsoft.com/powershell/module/az.cosmosdb
# --------------------------------------------------
# Purpose
# Migrate a keyspace or table to autoscale or standard (manual) throughput
# --------------------------------------------------
# Variables - ***** SUBSTITUTE YOUR VALUES *****
$resourceGroupName = "myResourceGroup" # Resource Group must already exist
$accountName = "myaccount" # Must be all lower case
$keyspaceName = "myKeyspace"
$tableName = "myTable"
# --------------------------------------------------
Write-Host "Migrate keyspace with standard throughput to autoscale throughput."
Invoke-AzCosmosDBCassandraKeyspaceThroughputMigration -ResourceGroupName $resourceGroupName `
-AccountName $accountName -Name $keyspaceName -ThroughputType Autoscale
Write-Host "Migrate keyspace with autoscale throughput to standard throughput."
Invoke-AzCosmosDBCassandraKeyspaceThroughputMigration -ResourceGroupName $resourceGroupName `
-AccountName $accountName -Name $keyspaceName -ThroughputType Manual
Write-Host "Migrate table with standard throughput to autoscale throughput."
Invoke-AzCosmosDBCassandraTableThroughputMigration -ResourceGroupName $resourceGroupName `
-AccountName $accountName -KeyspaceName $keyspaceName -Name $tableName -ThroughputType Autoscale
Write-Host "Migrate table with autoscale throughput to standard throughput."
Invoke-AzCosmosDBCassandraTableThroughputMigration -ResourceGroupName $resourceGroupName `
-AccountName $accountName -KeyspaceName $keyspaceName -Name $tableName -ThroughputType Manual
Bersihkan penyebaran
Setelah sampel skrip dijalankan, perintah berikut dapat digunakan untuk menghapus grup sumber daya dan semua sumber daya yang terkait.
Remove-AzResourceGroup -ResourceGroupName "myResourceGroup"
Penjelasan skrip
Skrip ini menggunakan perintah berikut. Setiap perintah dalam tabel ditautkan ke dokumentasi spesifik perintah.
Perintah | Catatan |
---|---|
Azure Cosmos DB | |
Get-AzCosmosDBCassandraKeyspaceThroughput | Mendapatkan nilai throughput API untuk Cassandra Keyspace. |
Get-AzCosmosDBCassandraTableThroughput | Mendapatkan nilai throughput API untuk Tabel Cassandra. |
Update-AzCosmosDBCassandraKeyspaceThroughput | Memperbarui nilai throughput API untuk Cassandra Keyspace. |
Update-AzCosmosDBCassandraTableThroughput | Memperbarui nilai throughput API untuk Tabel Cassandra. |
Invoke-AzCosmosDBCassandraKeyspaceThroughputMigration | Memigrasikan throughput untuk API untuk Cassandra Keyspace. |
Invoke-AzCosmosDBCassandraTableThroughputMigration | Memigrasikan throughput untuk API untuk Tabel Cassandra. |
Grup Sumber Daya Azure | |
Remove-AzResourceGroup | Menghapus grup sumber daya termasuk semua sumber daya berlapis. |
Langkah berikutnya
Untuk informasi selengkapnya tentang Azure PowerShell, lihat dokumentasi Azure PowerShell.