Azure CLI를 사용하여 자동 스케일링되는 API for Gremlin 계정, 데이터베이스 및 그래프 만들기

적용 대상: Gremlin

이 문서의 스크립트는 자동 스케일링되는 Azure Cosmos DB for Gremlin 계정, 데이터베이스 및 그래프를 만듭니다.

필수 조건

  • Azure를 구독하고 있지 않다면 시작하기 전에 Azure 체험 계정을 만듭니다.

  • 이 스크립트에는 Azure CLI 버전 2.30 이상이 필요합니다.

    • Azure Cloud Shell의 Bash 환경에서 스크립트를 실행할 수 있습니다. Cloud Shell이 열리면 셸 창의 왼쪽 상단에 있는 환경 필드에서 Bash를 선택해야 합니다. Cloud Shell에는 최신 버전의 Azure CLI가 있습니다.

    • 원하는 경우 Azure CLI를 설치하여 스크립트를 로컬에서 실행할 수 있습니다. az version을 실행하여 Azure CLI 버전을 찾고 업그레이드가 필요한 경우 az upgrade를 실행합니다. az login을 실행하여 Azure에 로그인합니다.

샘플 스크립트

이 스크립트는 다음 명령을 사용합니다.

  • az group create는 모든 리소스를 저장할 리소스 그룹을 만듭니다.
  • --capabilities EnableGremlin 매개 변수를 사용한 az cosmosdb create는 Gremlin 지원 Azure Cosmos DB 계정을 만듭니다.
  • az cosmosdb gremlin database create는 Azure Cosmos DB for Gremlin 데이터베이스를 만듭니다.
  • az cosmosdb gremlin graph create--max-throughput 매개 변수를 최소 4000으로 설정하여 자동 스케일링되는 Azure Cosmos DB for Gremlin 그래프를 만듭니다.
# Create a Gremlin API database and graph with autoscale

# Variable block
let "randomIdentifier=$RANDOM*$RANDOM"
location="East US"
resourceGroup="msdocs-cosmosdb-rg-$randomIdentifier"
tag="autoscale-gremlin-cosmosdb"
account="msdocs-account-cosmos-$randomIdentifier" #needs to be lower case
database="msdocs-db-gremlin-cosmos"
graph="msdocs-graph1-gremlin-cosmos"
partitionKey="/partitionKey"
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 Gremlin API
echo "Creating $account"
az cosmosdb create --name $account --resource-group $resourceGroup --capabilities EnableGremlin --default-consistency-level Eventual --locations regionName="$location" failoverPriority=0 isZoneRedundant=False

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

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

리소스 삭제

스크립트에서 만든 리소스가 필요하지 않은 경우 az group delete 명령을 사용하여 Azure Cosmos DB 계정 및 데이터베이스를 포함하여 리소스 그룹과 여기에 포함된 모든 리소스를 삭제합니다.

az group delete --name $resourceGroup

다음 단계

Azure Cosmos DB CLI 설명서