Tworzenie konta bezserwerowego i tabeli przy użyciu interfejsu wiersza polecenia platformy Azure

DOTYCZY: Stół

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

Wymagania wstępne

Przykładowy skrypt

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

# Create a Table API serverless account and table

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

# 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 EnableServerless --default-consistency-level Eventual --locations regionName="$location" failoverPriority=0 isZoneRedundant=False \

# Create a Table API Table
az cosmosdb table create --account-name $account --resource-group $resourceGroup --name $table

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 EnableServerless tworzy konto bezserwerowe usługi Azure Cosmos DB dla interfejsu API dla tabeli.
  • az cosmosdb table create tworzy tabelę usługi Azure Cosmos DB dla tabel.

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

Dokumentacja interfejsu wiersza polecenia usługi Azure Cosmos DB