Durchsatzvorgänge (RU/s) mit PowerShell für eine Tabelle für Azure Cosmos DB: API für Table

GILT FÜR: Tabelle

Hinweis

Es wird empfohlen, das Azure Az PowerShell-Modul für die Interaktion mit Azure zu verwenden. Informationen zu den ersten Schritten finden Sie unter Installieren von Azure PowerShell. Informationen zum Migrieren zum Az PowerShell-Modul finden Sie unter Migrieren von Azure PowerShell von AzureRM zum Az-Modul.

Für dieses Beispiel ist mindestens Azure PowerShell Az 5.4.0 erforderlich. Führen Sie Get-Module -ListAvailable Az aus, um die installierten Versionen zu ermitteln. Wenn Sie die Installation ausführen müssen, finden Sie unter Installieren des Azure PowerShell-Moduls Informationen dazu.

Führen Sie zum Anmelden bei Azure Connect-AzAccount aus.

Durchsatzberechnung

# Reference: Az.CosmosDB | https://docs.microsoft.com/powershell/module/az.cosmosdb
# --------------------------------------------------
# Purpose
# Get RU/s throughput for Azure Cosmos DB Table API table
# --------------------------------------------------
# Variables - ***** SUBSTITUTE YOUR VALUES *****
$resourceGroupName = "myResourceGroup" # Resource Group must already exist
$accountName = "myaccount" # Must be all lower case
$tableName = "myTable"
# --------------------------------------------------

Get-AzCosmosDBTableThroughput -ResourceGroupName $resourceGroupName `
    -AccountName $accountName -Name $tableName

Aktualisieren des Durchsatzes

# 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
$tableName = "myTable"
$newRUs = 500
# --------------------------------------------------

$throughput = Get-AzCosmosDBTableThroughput -ResourceGroupName $resourceGroupName `
    -AccountName $accountName -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-AzCosmosDBTableThroughput -ResourceGroupName $resourceGroupName `
        -AccountName $accountName -Name $tableName `
        -Throughput $newRUs
}

Migrieren des Durchsatzes

# Reference: Az.CosmosDB | https://docs.microsoft.com/powershell/module/az.cosmosdb
# --------------------------------------------------
# Purpose
# Migrate a 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
$tableName = "myTable"
# --------------------------------------------------

Write-Host "Migrate table with standard throughput to autoscale throughput."
Invoke-AzCosmosDBTableThroughputMigration -ResourceGroupName $resourceGroupName `
    -AccountName $accountName -Name $tableName -ThroughputType Autoscale

Write-Host "Migrate table with autoscale throughput to standard throughput."
Invoke-AzCosmosDBTableThroughputMigration -ResourceGroupName $resourceGroupName `
    -AccountName $accountName -Name $tableName -ThroughputType Manual

Bereinigen der Bereitstellung

Nach Ausführung des Skriptbeispiels können mit dem folgenden Befehl die Ressourcengruppe und alle damit verbundenen Ressourcen entfernt werden.

Remove-AzResourceGroup -ResourceGroupName "myResourceGroup"

Erläuterung des Skripts

Das Skript verwendet die folgenden Befehle. Jeder Befehl in der Tabelle ist mit der zugehörigen Dokumentation verknüpft.

Get-Help Notizen
Azure Cosmos DB
Get-AzCosmosDBTableThroughput Ruft den Durchsatzwert der angegebenen API für Table-Tabelle ab.
Update-AzCosmosDBMongoDBCollectionThroughput Aktualisiert den Durchsatzwert der angegebenen API für Table-Tabelle.
Invoke-AzCosmosDBTableThroughputMigration Migriert den Durchsatz einer API für Table-Tabelle.
Azure-Ressourcengruppen
Remove-AzResourceGroup Löscht eine Ressourcengruppe einschließlich aller geschachtelten Ressourcen.

Nächste Schritte

Weitere Informationen zu Azure PowerShell finden Sie in der Azure PowerShell-Dokumentation.