Átviteli sebesség (RU/s) műveletek a PowerShell-lel az Azure Cosmos DB kulcsteréhez vagy tábláihoz – API a Cassandra-hoz
A KÖVETKEZŐKRE VONATKOZIK: Cassandra
Feljegyzés
Javasoljuk, hogy az Azure Az PowerShell modult használja az Azure-ral való interakcióhoz. Első lépésként tekintse meg az Azure PowerShell telepítését ismertető témakört. Az Az PowerShell-modulra történő migrálás részleteiről lásd: Az Azure PowerShell migrálása az AzureRM modulból az Az modulba.
Ehhez a mintához az Azure PowerShell Az 5.4.0-s vagy újabb verziója szükséges. Futtassa Get-Module -ListAvailable Az
a telepített verziókat.
Ha telepítenie kell, tekintse meg az Azure PowerShell-modul telepítését ismertető témakört.
A Connect-AzAccount futtatásával jelentkezzen be az Azure-ba.
Átviteli sebesség lekérdezése
# 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
Átviteli sebesség frissítése
# 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
}
Átviteli sebesség migrálása
# 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
Az üzemelő példány eltávolítása
A példaszkript futtatása után a következő paranccsal távolítható el az erőforráscsoport és az összes ahhoz kapcsolódó erőforrás.
Remove-AzResourceGroup -ResourceGroupName "myResourceGroup"
Szkript ismertetése
A szkript a következő parancsokat használja. A táblázatban lévő összes parancs a hozzá tartozó dokumentációra hivatkozik.
Parancs | Jegyzetek |
---|---|
Azure Cosmos DB | |
Get-AzCosmosDBCassandraKeyspaceThroughput | Lekéri a Cassandra Keyspace API átviteli sebességének értékét. |
Get-AzCosmosDBCassandraTableThroughput | Lekéri a Cassandra-tábla API átviteli sebességének értékét. |
Update-AzCosmosDBCassandraKeyspaceThroughput | Frissíti a Cassandra Keyspace API átviteli sebességének értékét. |
Update-AzCosmosDBCassandraTableThroughput | Frissíti a Cassandra-tábla API átviteli sebességének értékét. |
Invoke-AzCosmosDBCassandraKeyspaceThroughputMigration | A Cassandra Keyspace API átviteli sebességének migrálása. |
Invoke-AzCosmosDBCassandraTableThroughputMigration | A Cassandra-tábla API-jának átviteli sebességének migrálása. |
Azure-erőforráscsoportok | |
Remove-AzResourceGroup | Töröl egy erőforráscsoportot az összes beágyazott erőforrással együtt. |
Következő lépések
Az Azure PowerShellről további tudnivalókért tekintse meg az Azure PowerShell dokumentációt.