Używanie interfejsu wiersza polecenia platformy Azure do tworzenia usługi Azure Cosmos DB dla konta tabel i tabeli za pomocą autoskalowania

DOTYCZY: Tabeli

Skrypt w tym artykule tworzy usługę Azure Cosmos DB dla konta tabeli i tabeli z autoskalowaniem.

Wymagania wstępne

Przykładowy skrypt

Uruchom następujący skrypt, aby utworzyć grupę zasobów platformy Azure, konto usługi Azure Cosmos DB dla tabel i interfejs API dla tabeli tabel z możliwością automatycznego skalowania. Tworzenie zasobów może zająć trochę czasu.

# Create a Table API table with autoscale

# Variable block
let "randomIdentifier=$RANDOM*$RANDOM"
location="East US"
resourceGroup="msdocs-cosmosdb-rg-$randomIdentifier"
tag="autoscale-table-cosmosdb"
account="msdocs-account-cosmos-$randomIdentifier" #needs to be lower case
table="msdocs-table-cosmos-$randomIdentifier"
maxThroughput=1000 #minimum = 1000

# Create a resource group
echo "Creating $resourceGroup in $location..."
az group create --name $resourceGroup --location "$location" --tags $tag

# Create a Cosmos account for Table API
echo "Creating $account"
az cosmosdb create --name $account --resource-group $resourceGroup --capabilities EnableTable --default-consistency-level Eventual --locations regionName="$location" failoverPriority=0 isZoneRedundant=False

# Create a Table API Table with autoscale
echo "Create $table with $maxThroughput"
az cosmosdb table create --account-name $account --resource-group $resourceGroup --name $table --max-throughput $maxThroughput

W tym skrypcie użyto następujących poleceń:

  • az group create tworzy grupę zasobów do przechowywania wszystkich zasobów.
  • az cosmosdb create with --capabilities EnableTable tworzy konto usługi Azure Cosmos DB dla interfejsu API dla tabeli.
  • az cosmosdb table create with create an Azure Cosmos DB for Table table with autoscale capabilities (az cosmosdb table with --max-throughput 1000 create with create an Azure Cosmos DB for Table table with autoscale capabilities).

Czyszczenie zasobów

Jeśli nie potrzebujesz już utworzonych zasobów, użyj polecenia az group delete , aby usunąć grupę zasobów i wszystkie zawarte w niej zasoby. Te zasoby obejmują konto i tabelę usługi Azure Cosmos DB. Usunięcie zasobów może zająć trochę czasu.

az group delete --name $resourceGroup

Następne kroki