NoSQL için Azure Cosmos DB veritabanı veya kapsayıcısı için PowerShell ile aktarım hızı (RU/sn) işlemleri
ŞUNUN IÇIN GEÇERLIDIR: NoSQL
Not
Azure ile etkileşime geçmek 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 az 5.4.0 veya sonraki Azure PowerShell gerektirir. 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 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
Aktarım hızını güncelleştirme
# 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
}
Aktarım hızını geçirme
# 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
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.
Komut | Notlar |
---|---|
Azure Cosmos DB | |
Get-AzCosmosDBSqlDatabaseThroughput | NoSQL için Azure Cosmos DB Veritabanında sağlanan aktarım hızını elde edin. |
Get-AzCosmosDBSqlContainerThroughput | NoSQL için Azure Cosmos DB Kapsayıcısı üzerinde sağlanan aktarım hızını elde edin. |
Update-AzCosmosDBSqlDatabaseThroughput | NoSQL için Azure Cosmos DB Veritabanının aktarım hızı değerini Güncelleştirmeler. |
Update-AzCosmosDBSqlContainerThroughput | NoSQL için Azure Cosmos DB Kapsayıcısının aktarım hızı değerini Güncelleştirmeler. |
Invoke-AzCosmosDBSqlDatabaseThroughputMigration | NoSQL için Azure Cosmos DB Veritabanının aktarım hızını geçirme. |
Invoke-AzCosmosDBSqlContainerThroughputMigration | NoSQL için Azure Cosmos DB Kapsayıcısının 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.