Aracılığıyla paylaş


MongoDB için Azure Cosmos DB için veritabanı veya koleksiyon için PowerShell ile aktarım hızı (RU/sn) işlemleri

ŞUNLAR IÇIN GEÇERLIDIR: MongoDB

Not

Azure ile etkileşim kurmak için Azure Az PowerShell modülünü kullanmanızı öneririz. Başlamak için bkz . Azure PowerShell'i yükleme. Az PowerShell modülüne nasıl geçeceğinizi öğrenmek için bkz. Azure PowerShell’i AzureRM’den Az’ye geçirme.

Bu örnek Için Azure PowerShell Az 5.4.0 veya üzeri gerekir. Hangi sürümlerin yüklü olduğunu görmek için komutunu çalıştırın Get-Module -ListAvailable Az . Yüklemeniz gerekiyorsa bkz . Azure PowerShell modülünü yükleme.

Azure'da oturum açmak için Connect-AzAccount komutunu çalıştırın.

Aktarım hızı alma

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

Write-Host "Get database shared throughput"
Get-AzCosmosDBMongoDBDatabaseThroughput -ResourceGroupName $resourceGroupName `
    -AccountName $accountName -Name $databaseName

Write-Host "Get collection dedicated throughput"
Get-AzCosmosDBMongoDBCollectionThroughput -ResourceGroupName $resourceGroupName `
    -AccountName $accountName -DatabaseName $databaseName `
    -Name $collectionName

Aktarım hızını güncelleştirme

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

$throughput = Get-AzCosmosDBMongoDBCollectionThroughput -ResourceGroupName $resourceGroupName `
    -AccountName $accountName -DatabaseName $databaseName -Name $collectionName

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

Aktarım hızını geçirme

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

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

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

Write-Host "Migrate collection with standard throughput to autoscale throughput."
Invoke-AzCosmosDBMongoDBCollectionThroughputMigration -ResourceGroupName $resourceGroupName `
    -AccountName $accountName -DatabaseName $databaseName -Name $collectionName -ThroughputType Autoscale

Write-Host "Migrate collection with autoscale throughput to standard throughput."
Invoke-AzCosmosDBMongoDBCollectionThroughputMigration -ResourceGroupName $resourceGroupName `
    -AccountName $accountName -DatabaseName $databaseName -Name $collectionName -ThroughputType Manual

Dağıtımı temizleme

Betik örneği çalıştırıldıktan sonra, kaynak grubunu ve onunla ilişkili tüm kaynakları kaldırmak için aşağıdaki komut kullanılabilir.

Remove-AzResourceGroup -ResourceGroupName "myResourceGroup"

Betik açıklaması

Bu betik aşağıdaki komutları kullanır. Tablodaki her komut, komuta özgü belgelere yönlendirir.

Command Notlar
Azure Cosmos DB
Get-AzCosmosDBMongoDBDatabaseThroughput MongoDB veritabanı için belirtilen Azure Cosmos DB'nin aktarım hızı değerini alır.
Get-AzCosmosDBMongoDBCollectionThroughput MongoDB koleksiyonu için belirtilen Azure Cosmos DB'nin aktarım hızı değerini alır.
Update-AzCosmosDBMongoDBDatabaseThroughput MongoDB veritabanı için Azure Cosmos DB'nin aktarım hızı değerini güncelleştirir.
Update-AzCosmosDBMongoDBCollectionThroughput MongoDB için Azure Cosmos DB Koleksiyonunun aktarım hızı değerini güncelleştirir.
Invoke-AzCosmosDBMongoDBDatabaseThroughputMigration MongoDB için Azure Cosmos DB Koleksiyonunun aktarım hızını geçirme.
Invoke-AzCosmosDBMongoDBCollectionThroughputMigration MongoDB için Azure Cosmos DB Koleksiyonunun aktarım hızını geçirme.
Azure Kaynak Grupları
Remove-AzResourceGroup Bir kaynak grubunu tüm iç içe geçmiş kaynaklar dahil siler.

Sonraki adımlar

Azure PowerShell hakkında daha fazla bilgi için bkz. Azure PowerShell belgeleri.