Doorvoerbewerkingen (RU/s) met PowerShell voor een database of grafiek voor Azure Cosmos DB - API voor Gremlin
VAN TOEPASSING OP: Gremlin
Notitie
Het wordt aanbevolen de Azure Az PowerShell-module te gebruiken om te communiceren met Azure. Zie Azure PowerShell installeren om aan de slag te gaan. Raadpleeg Azure PowerShell migreren van AzureRM naar Az om te leren hoe u naar de Azure PowerShell-module migreert.
Voor dit voorbeeld is Azure PowerShell Az 5.4.0 of hoger vereist. Voer Get-Module -ListAvailable Az
uit om te zien welke versies zijn geïnstalleerd.
Als u PowerShell moet installeren, raadpleegt u De Azure PowerShell-module installeren.
Voer Connect-AzAccount uit om u aan te melden bij Azure.
Doorvoer bepalen
# Reference: Az.CosmosDB | https://docs.microsoft.com/powershell/module/az.cosmosdb
# --------------------------------------------------
# Purpose
# Get database or graph throughput
# --------------------------------------------------
# Variables - ***** SUBSTITUTE YOUR VALUES *****
$resourceGroupName = "myResourceGroup" # Resource Group must already exist
$accountName = "myaccount" # Must be all lower case
$databaseName = "myDatabase"
$graphName = "myGraph"
# --------------------------------------------------
Write-Host "Get database shared throughput"
Get-AzCosmosDBGremlinDatabaseThroughput -ResourceGroupName $resourceGroupName `
-AccountName $accountName -Name $databaseName
Write-Host "Get graph dedicated throughput"
Get-AzCosmosDBGremlinGraphThroughput -ResourceGroupName $resourceGroupName `
-AccountName $accountName -DatabaseName $databaseName `
-Name $graphName
Doorvoer bijwerken
# Reference: Az.CosmosDB | https://docs.microsoft.com/powershell/module/az.cosmosdb
# --------------------------------------------------
# Purpose
# Update graph throughput
# --------------------------------------------------
# Variables - ***** SUBSTITUTE YOUR VALUES *****
$resourceGroupName = "myResourceGroup" # Resource Group must already exist
$accountName = "myaccount" # Must be all lower case
$databaseName = "myDatabase"
$graphName = "myGraph"
$newRUs = 500
# --------------------------------------------------
$throughput = Get-AzCosmosDBGremlinGraphThroughput `
-ResourceGroupName $resourceGroupName `
-AccountName $accountName -DatabaseName $databaseName `
-Name $graphName
$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-AzCosmosDBGremlinGraphThroughput -ResourceGroupName $resourceGroupName `
-AccountName $accountName -DatabaseName $databaseName `
-Name $graphName -Throughput $newRUs
}
Doorvoer migreren
# Reference: Az.CosmosDB | https://docs.microsoft.com/powershell/module/az.cosmosdb
# --------------------------------------------------
# Purpose
# Migrate a database or graph 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"
$graphName = "myGraph"
# --------------------------------------------------
Write-Host "Migrate database with standard throughput to autoscale throughput."
Invoke-AzCosmosDBGremlinDatabaseThroughputMigration -ResourceGroupName $resourceGroupName `
-AccountName $accountName -Name $databaseName -ThroughputType Autoscale
Write-Host "Migrate database with autoscale throughput to standard throughput."
Invoke-AzCosmosDBGremlinDatabaseThroughputMigration -ResourceGroupName $resourceGroupName `
-AccountName $accountName -Name $databaseName -ThroughputType Manual
Write-Host "Migrate graph with standard throughput to autoscale throughput."
Invoke-AzCosmosDBGremlinGraphThroughputMigration -ResourceGroupName $resourceGroupName `
-AccountName $accountName -DatabaseName $databaseName -Name $graphName -ThroughputType Autoscale
Write-Host "Migrate graph with autoscale throughput to standard throughput."
Invoke-AzCosmosDBGremlinGraphThroughputMigration -ResourceGroupName $resourceGroupName `
-AccountName $accountName -DatabaseName $databaseName -Name $graphName -ThroughputType Manual
Opschonen van implementatie
Na het uitvoeren van het voorbeeldscript kan de volgende opdracht worden gebruikt om de resourcegroep en alle resources die er aan zijn gekoppeld te verwijderen.
Remove-AzResourceGroup -ResourceGroupName "myResourceGroup"
Uitleg van het script
In dit script worden de volgende opdrachten gebruikt. Elke opdracht in de tabel is een koppeling naar specifieke documentatie over de opdracht.
Opdracht | Opmerkingen |
---|---|
Azure Cosmos DB | |
Get-AzCosmosDBGremlinDatabaseThroughput | Hiermee haalt u de doorvoerwaarde van de API voor Gremlin Database op. |
Get-AzCosmosDBGremlinGraphThroughput | Hiermee haalt u de doorvoerwaarde van de API voor Gremlin Graph op. |
Update-AzCosmosDBGremlinDatabaseThroughput | Hiermee wordt de doorvoerwaarde van de API voor Gremlin Database bijgewerkt. |
Update-AzCosmosDBGremlinGraphThroughput | Hiermee wordt de doorvoerwaarde van de API voor Gremlin Graph bijgewerkt. |
Invoke-AzCosmosDBGremlinDatabaseThroughputMigration | Migreer doorvoer van een API voor Gremlin Database. |
Invoke-AzCosmosDBGremlinGraphThroughputMigration | Migreer doorvoer van een API voor Gremlin Graph. |
Azure-resourcegroepen | |
Remove-AzResourceGroup | Hiermee verwijdert u een resourcegroep met inbegrip van alle ingesloten resources. |
Volgende stappen
Zie Documentatie over Azure PowerShell voor meer informatie over Azure PowerShell.