Átviteli sebesség (RU/s) műveletek a NoSQL-hez készült Azure Cosmos DB adatbázisához vagy tárolóihoz készült PowerShell-lel

A KÖVETKEZŐRE VONATKOZIK: NoSQL

Megjegyzés

Javasoljuk, hogy az Azure Az PowerShell-modult használja az Azure-ral való kommunikációhoz. Az első lépésekhez tekintse meg az Azure PowerShell telepítését ismertető szakaszt. 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 Azure PowerShell Az 5.4.0-s vagy újabb verzióra van szükség. Futtassa a parancsot Get-Module -ListAvailable Az a telepített verziók megtekintéséhez. Ha telepítenie kell, olvassa el a Azure PowerShell telepítése modult.

Az Azure-ba való bejelentkezéshez futtassa a Connect-AzAccount parancsot .

Átviteli sebesség lekérdezése

# Reference: Az.CosmosDB | https://docs.microsoft.com/powershell/module/az.cosmosdb
# --------------------------------------------------
# Purpose
# Get database or container throughput
# --------------------------------------------------
# Variables - ***** SUBSTITUTE YOUR VALUES *****
$resourceGroupName = "myResourceGroup" # Resource Group must already exist
$accountName = "myaccount" # Must be all lower case
$databaseName = "myDatabase"
$containerName = "myContainer"
# --------------------------------------------------

Write-Host "Get database shared throughput - if none provisioned, will return error."
Get-AzCosmosDBSqlDatabaseThroughput -ResourceGroupName $resourceGroupName `
    -AccountName $accountName -Name $databaseName

Write-Host "Get container dedicated throughput - if none provisioned, will return error."
Get-AzCosmosDBSqlContainerThroughput -ResourceGroupName $resourceGroupName `
    -AccountName $accountName -DatabaseName $databaseName `
    -Name $containerName

Átviteli sebesség frissítése

# Reference: Az.CosmosDB | https://docs.microsoft.com/powershell/module/az.cosmosdb
# --------------------------------------------------
# Purpose
# Update container throughput
# --------------------------------------------------
# Variables - ***** SUBSTITUTE YOUR VALUES *****
$resourceGroupName = "myResourceGroup" # Resource Group must already exist
$accountName = "myaccount" # Must be all lower case
$databaseName = "myDatabase"
$containerName = "myContainer"
$newRUs = 500
# --------------------------------------------------

$throughput = Get-AzCosmosDBSqlContainerThroughput -ResourceGroupName $resourceGroupName `
    -AccountName $accountName -DatabaseName $databaseName -Name $containerName

$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-AzCosmosDBSqlContainerThroughput -ResourceGroupName $resourceGroupName `
        -AccountName $accountName -DatabaseName $databaseName `
        -Name $containerName -Throughput $newRUs
}

Átviteli sebesség migrálása

# Reference: Az.CosmosDB | https://docs.microsoft.com/powershell/module/az.cosmosdb
# --------------------------------------------------
# Purpose
# Migrate a database or container to autoscale or standard (manual) throughput
# --------------------------------------------------
# Variables - ***** SUBSTITUTE YOUR VALUES *****
$resourceGroupName = "myResourceGroup" # Resource Group must already exist
$accountName = "myaccount" # Must be all lower case
$databaseName = "myDatabase"
$containerName = "myContainer"
# --------------------------------------------------

Write-Host "Migrate database with standard throughput to autoscale throughput."
Invoke-AzCosmosDBSqlDatabaseThroughputMigration -ResourceGroupName $resourceGroupName `
    -AccountName $accountName -Name $databaseName -ThroughputType Autoscale

Write-Host "Migrate database with autoscale throughput to standard throughput."
Invoke-AzCosmosDBSqlDatabaseThroughputMigration -ResourceGroupName $resourceGroupName `
    -AccountName $accountName -Name $databaseName -ThroughputType Manual

Write-Host "Migrate container with standard throughput to autoscale throughput."
Invoke-AzCosmosDBSqlContainerThroughputMigration -ResourceGroupName $resourceGroupName `
    -AccountName $accountName -DatabaseName $databaseName -Name $containerName -ThroughputType Autoscale

Write-Host "Migrate container with autoscale throughput to standard throughput."
Invoke-AzCosmosDBSqlContainerThroughputMigration -ResourceGroupName $resourceGroupName `
    -AccountName $accountName -DatabaseName $databaseName -Name $containerName -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-AzCosmosDBSqlDatabaseThroughput Szerezze be a NoSQL-adatbázishoz készült Azure Cosmos DB-n kiosztott átviteli sebességet.
Get-AzCosmosDBSqlContainerThroughput Szerezze be a NoSQL-tárolóhoz készült Azure Cosmos DB-n kiosztott átviteli sebességet.
Update-AzCosmosDBSqlDatabaseThroughput Frissítések a NoSQL-adatbázishoz készült Azure Cosmos DB átviteli sebességértékét.
Update-AzCosmosDBSqlContainerThroughput Frissítések egy Azure Cosmos DB for NoSQL-tároló átviteli sebességértékét.
Invoke-AzCosmosDBSqlDatabaseThroughputMigration Egy Azure Cosmos DB for NoSQL-adatbázis átviteli sebességének migrálása.
Invoke-AzCosmosDBSqlContainerThroughputMigration Egy Azure Cosmos DB for NoSQL-tároló á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.