Megosztás a következőn keresztül:


Átviteli sebesség (RU/s) műveletek az Azure CLI-vel adatbázishoz vagy gráfhoz az Azure Cosmos DB-hez – API a Gremlinhez

If you don't have an Azure subscription, create an Azure free account before you begin.

A cikkben szereplő szkript létrehoz egy Gremlin-adatbázist megosztott átviteli sebességgel és egy dedikált átviteli sebességgel rendelkező Gremlin-gráfot, majd frissíti az adatbázis és a gráf átviteli sebességét. A szkript ezután a standardról az automatikus skálázási átviteli sebességre migrál, majd beolvassa az automatikus skálázási átviteli sebesség értékét a migrálás után.

Előfeltételek

  • Ez a cikk a 2.30-es vagy újabb verziót igényli. A verzió azonosításához futtassa a következőt: az --version. Ha telepíteni vagy frissíteni szeretne: Az Azure CLI telepítése. Az Azure Cloud Shell használata esetén a legújabb verzió már telepítve van.

Példaszkript

Az Azure Cloud Shell elindítása

Az Azure Cloud Shell egy olyan ingyenes interaktív kezelőfelület, amelyet a jelen cikkben található lépések futtatására használhat. A fiókjával való használat érdekében a gyakran használt Azure-eszközök már előre telepítve és konfigurálva vannak rajta.

A Cloud Shell megnyitásához válassza a Kipróbálás lehetőséget egy kódblokk jobb felső sarkában. A Cloud Shellt egy külön böngészőlapon is elindíthatja a https://shell.azure.com cím megnyitásával.

Amikor megnyílik a Cloud Shell, ellenőrizze, hogy a Bash ki van-e jelölve a környezetében. A következő munkamenetek az Azure CLI-t használják Bash-környezetben, a Másolás lehetőséget választva másolja ki a kódblokkokat, illessze be a Cloud Shellbe, és nyomja le az Enter billentyűt a futtatáshoz.

Bejelentkezés az Azure-ba

A Cloud Shell automatikusan hitelesítve lesz a kezdeti fiókkal, amellyel bejelentkezett. A következő szkripttel egy másik előfizetéssel jelentkezhet be, lecserélve <Subscription ID> az Azure-előfizetés azonosítóját. If you don't have an Azure subscription, create an Azure free account before you begin.

subscription="<subscriptionId>" # add subscription here

az account set -s $subscription # ...or use 'az login'

További információ: Aktív előfizetés beállítása vagy interaktív bejelentkezés

A szkript futtatása

# Throughput operations for a Gremlin API database and graph

# Variable block
let "randomIdentifier=$RANDOM*$RANDOM"
location="East US"
resourceGroup="msdocs-cosmosdb-rg-$randomIdentifier"
tag="throughput-gremlin-cosmosdb"
account="msdocs-account-cosmos-$randomIdentifier" #needs to be lower case
database="msdocs-db-gremlin-cosmos"
graph="msdocs-graph1-gremlin-cosmos"
partitionKey="/partitionKey"
originalThroughput=400
updateThroughput=500

# Create a resource group 
az group create --name $resourceGroup --location "$location" --tags $tag

# Create a Cosmos account for Gremlin API
echo "Creating $account"
az cosmosdb create --name $account --resource-group $resourceGroup --capabilities EnableGremlin

# Create Gremlin database with throughput
echo "Creating $database with $originalThroughput"
az cosmosdb gremlin database create --account-name $account --resource-group $resourceGroup --name $database --throughput $originalThroughput

# Create Gremlin graph with throughput 
echo "Creating $graph with $originalThroughput"
az cosmosdb gremlin graph create --account-name $account --resource-group $resourceGroup --database-name $database --name $graph --partition-key-path $partitionKey --throughput $originalThroughput

# Throughput operations for Gremlin API database
#   Read the current throughput
#   Read the minimum throughput
#   Make sure the updated throughput is not less than the minimum
#   Update the throughput
#   Migrate between standard (manual) and autoscale throughput
#   Read the autoscale max throughput

# Retrieve the current provisioned database throughput
az cosmosdb gremlin database throughput show --resource-group $resourceGroup --account-name $account --name $database --query resource.throughput -o tsv

# Retrieve the minimum allowable database throughput
minimumThroughput=$(az cosmosdb gremlin database throughput show --resource-group $resourceGroup --account-name $account --name $database --query resource.minimumThroughput -o tsv)

echo $minimumThroughput

# Make sure the updated throughput is not less than the minimum allowed throughput
if [ $updateThroughput -lt $minimumThroughput ]; then
    updateThroughput=$minimumThroughput
fi

# Update database throughput
echo "Updating $database throughput to $updateThroughput"
az cosmosdb gremlin database throughput update --account-name $account --resource-group $resourceGroup --name $database --throughput $updateThroughput

# Migrate the database from standard (manual) throughput to autoscale throughput
az cosmosdb gremlin database throughput migrate --account-name $account --resource-group $resourceGroup --name $database --throughput-type "autoscale"

# Retrieve current autoscale provisioned max database throughput
az cosmosdb gremlin database throughput show --resource-group $resourceGroup --account-name $account --name $database --query resource.autoscaleSettings.maxThroughput -o tsv

# Throughput operations for Gremlin API graph
#   Read the current throughput
#   Read the minimum throughput
#   Make sure the updated throughput is not less than the minimum
#   Update the throughput
#   Migrate between standard (manual) and autoscale throughput
#   Read the autoscale max throughput

# Retrieve the current provisioned graph throughput
az cosmosdb gremlin graph throughput show --resource-group $resourceGroup --account-name $account --database $database --name $graph --query resource.throughput -o tsv

# Retrieve the minimum allowable graph throughput
minimumThroughput=$(az cosmosdb gremlin graph throughput show --resource-group $resourceGroup --account-name $account --database $database --name $graph --query resource.minimumThroughput -o tsv)
echo $minimumThroughput

# Make sure the updated throughput is not less than the minimum allowed throughput
if [ $updateThroughput -lt $minimumThroughput ]; then
    updateThroughput=$minimumThroughput
fi

# Update graph throughput
echo "Updating $graph throughput to $updateThroughput"
az cosmosdb gremlin graph throughput update --resource-group $resourceGroup --account-name $account --database $database --name $graph --throughput $updateThroughput

# Migrate the graph from standard (manual) throughput to autoscale throughput
az cosmosdb gremlin graph throughput migrate --account-name $account --resource-group $resourceGroup --database $database --name $graph --throughput-type "autoscale"

# Retrieve the current autoscale provisioned max graph throughput
az cosmosdb gremlin graph throughput show --resource-group $resourceGroup --account-name $account --database $database --name $graph --query resource.autoscaleSettings.maxThroughput -o tsv

Clean up resources

Az alábbi paranccsal eltávolíthatja az erőforráscsoportot és a hozzá társított összes erőforrást az az csoporttörlés paranccsal – kivéve, ha folyamatosan szüksége van ezekre az erőforrásokra. Ezen erőforrások némelyikének létrehozása és törlése eltarthat egy ideig.

az group delete --name $resourceGroup

Mintahivatkozás

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
az group create Létrehoz egy erőforráscsoportot, amely az összes erőforrást tárolja.
az cosmosdb create Létrehoz egy Azure Cosmos DB-fiókot.
az cosmosdb gremlin database create Létrehoz egy Azure Cosmos DB-t Gremlin-adatbázishoz.
az cosmosdb gremlin graph create Létrehoz egy Azure Cosmos DB-t a Gremlin-gráfhoz.
az cosmosdb gremlin database throughput update Ru/s frissítése Egy Gremlin-adatbázishoz készült Azure Cosmos DB-hez.
az cosmosdb gremlin graph throughput update Ru/s frissítése egy Gremlin-gráfhoz készült Azure Cosmos DB-hez.
az cosmosdb gremlin database throughput migrate Átviteli sebesség migrálása Egy Gremlin-adatbázishoz készült Azure Cosmos DB-hez.
az cosmosdb gremlin graph átviteli sebesség migrálása Átviteli sebesség migrálása Egy Gremlin-gráfhoz készült Azure Cosmos DB-hez.
az group delete Töröl egy erőforráscsoportot az összes beágyazott erőforrással együtt.

Következő lépések

Az Azure Cosmos DB CLI-vel kapcsolatos további információkért tekintse meg az Azure Cosmos DB CLI dokumentációját.