Azure Cosmos DB for Gremlin 데이터베이스 및 그래프를 나열하거나 가져오는 PowerShell 스크립트
적용 대상: Gremlin
이 PowerShell 스크립트는 특정 Azure Cosmos DB 계정, API for Gremlin 데이터베이스 및 API for Gremlin 그래프를 나열하거나 가져옵니다.
참고 항목
Azure Az PowerShell 모듈을 사용하여 Azure와 상호 작용하는 것이 좋습니다. 시작하려면 Azure PowerShell 설치를 참조하세요. Az PowerShell 모듈로 마이그레이션하는 방법에 대한 자세한 내용은 Azure PowerShell을 AzureRM에서 Azure로 마이그레이션을 참조하세요.
필수 조건
이 샘플에는 Azure PowerShell Az 5.4.0 이상이 필요합니다.
Get-Module -ListAvailable Az
를 실행하여 설치된 버전을 확인합니다. 설치해야 하는 경우 Azure PowerShell 모듈 설치를 참조하세요.Connect-AzAccount를 실행하여 Azure에 로그인합니다.
샘플 스크립트
이 스크립트에서:
- Get-AzCosmosDBAccount는 Azure 리소스 그룹의 특정 Azure Cosmos DB 계정을 모두 나열하거나 가져옵니다.
- Get-AzCosmosDBGremlinDatabase는 Azure Cosmos DB 계정의 특정 API for Gremlin 데이터베이스를 모두 나열하거나 가져옵니다.
- Get-AzCosmosDBGremlinGraph는 API for Gremlin 데이터베이스의 모든 그래프를 나열하거나 특정 API for Gremlin 그래프를 가져옵니다.
# Reference: Az.CosmosDB | https://docs.microsoft.com/powershell/module/az.cosmosdb
# --------------------------------------------------
# Purpose
# List and get operations for accounts, databases, and graphs
# --------------------------------------------------
# Variables - ***** SUBSTITUTE YOUR VALUES *****
$resourceGroupName = "myResourceGroup" # Resource Group must already exist
$accountName = "myaccount" # Must be all lower case
$databaseName = "myDatabase"
$graphName = "myGraph"
# --------------------------------------------------
Write-Host "List all accounts in a resource group"
Get-AzCosmosDBAccount -ResourceGroupName $resourceGroupName
Write-Host "Get an account in a resource group"
Get-AzCosmosDBAccount -ResourceGroupName $resourceGroupName `
-Name $accountName
Write-Host "List all databases in an account"
Get-AzCosmosDBGremlinDatabase -ResourceGroupName $resourceGroupName `
-AccountName $accountName
Write-Host "Get a database in an account"
Get-AzCosmosDBGremlinDatabase -ResourceGroupName $resourceGroupName `
-AccountName $accountName -Name $databaseName
Write-Host "List all graphs in a database"
Get-AzCosmosDBGremlinGraph -ResourceGroupName $resourceGroupName `
-AccountName $accountName -DatabaseName $databaseName
Write-Host "Get a graph in a database"
Get-AzCosmosDBGremlinGraph -ResourceGroupName $resourceGroupName `
-AccountName $accountName -DatabaseName $databaseName `
-Name $graphName
Azure 리소스 그룹 삭제
Azure Cosmos DB 계정을 삭제하려는 경우 Remove-AzResourceGroup PowerShell 명령을 사용하여 해당 리소스 그룹을 제거할 수 있습니다. 이 명령은 Azure Cosmos DB 계정과 해당 컨테이너 및 데이터베이스를 포함하여 Azure 리소스 그룹과 그 안의 모든 리소스를 제거합니다.
Remove-AzResourceGroup -ResourceGroupName "myResourceGroup"
다음 단계
Azure PowerShell에 대한 자세한 내용은 Azure PowerShell 설명서를 참조하세요.