이 빠른 시작에서는 Bicep을 사용하여 새 Azure DocumentDB 클러스터를 배포합니다. 이 빠른 시작에서는 빠르게 시작하는 데 도움이 되는 단계별 지침을 제공합니다. 이 클러스터에는 모든 MongoDB 리소스(데이터베이스, 컬렉션 및 문서)가 포함됩니다. Azure DocumentDB에 연결하고 작업을 수행할 수 있는 도구 및 SDK(소프트웨어 개발 키트)에 대한 고유한 엔드포인트를 제공합니다.
필수 조건
Azure 구독
- Azure 구독이 없는 경우 체험 계정 만들기
Bash 환경을 Azure Cloud Shell에서 사용합니다. 자세한 내용은 Azure Cloud Shell 시작을 참조하세요.
CLI 참조 명령을 로컬에서 실행하려면 Azure CLI를 설치하십시오. Windows 또는 macOS에서 실행 중인 경우 Docker 컨테이너에서 Azure CLI를 실행하는 것이 좋습니다. 자세한 내용은 Docker 컨테이너에서 Azure CLI를 실행하는 방법을 참조하세요.
로컬 설치를 사용하는 경우 az login 명령을 사용하여 Azure CLI에 로그인합니다. 인증 프로세스를 완료하려면 터미널에 표시되는 단계를 수행합니다. 다른 로그인 옵션은 Azure CLI를 사용하여 Azure에 인증을 참조하세요.
메시지가 표시되면 처음 사용할 때 Azure CLI 확장을 설치합니다. 확장에 대한 자세한 내용은 Azure CLI로 확장 사용 및 관리를 참조하세요.
az version을 실행하여 설치된 버전과 관련 종속 라이브러리를 확인합니다. 최신 버전으로 업그레이드하려면 az upgrade를 실행합니다.
환경 구성
구독에서 Azure DocumentDB 리소스를 관리하도록 Azure CLI 환경을 설정합니다.
빈 디렉터리에서 시작합니다.
Azure CLI에 로그인합니다.
az login대상 Azure 구독을 확인합니다.
az account show비고
예상한 구독에 연결되지 않은 경우 다음 명령을 사용하여 구독을 변경합니다.
az account set --subscription "<subscription-name>"자세한 내용은 Azure CLI를 사용하여 Azure 구독 관리를 참조하세요.
Bicep 템플릿을 준비하세요.
Azure DocumentDB 클러스터를 배포하는 데 필요한 리소스를 정의하도록 Bicep 파일을 만들고 구성합니다.
프로젝트 디렉터리에 새 main.bicep 파일을 만듭니다.
파일의 콘텐츠에 이 템플릿을 추가합니다.
@description('Cluster name') @minLength(8) @maxLength(40) param clusterName string = 'msdocs-${uniqueString(resourceGroup().id)}' @description('Location for the cluster.') param location string = resourceGroup().location @description('Username for admin user') param adminUsername string @secure() @description('Password for admin user') @minLength(8) @maxLength(128) param adminPassword string resource cluster 'Microsoft.DocumentDB/mongoClusters@2025-09-01' = { name: clusterName location: location properties: { administrator: { userName: adminUsername password: adminPassword } serverVersion: '8.0' sharding: { shardCount: 1 } storage: { sizeGb: 32 } highAvailability: { targetMode: 'Disabled' } compute: { tier: 'M10' } } } resource firewallRules 'Microsoft.DocumentDB/mongoClusters/firewallRules@2025-09-01' = { parent: cluster name: 'AllowAllAzureServices' properties: { startIpAddress: '0.0.0.0' endIpAddress: '0.0.0.0' } }팁 (조언)
리소스를 사용하는
Microsoft.DocumentDB/mongoclusters옵션에 대한 자세한 내용은 설명서를 참조Microsoft.DocumentDB/mongoclusters하세요.
템플릿 배포
Azure Resource Manager 배포를 사용하여 이전 단계에서 만든 템플릿을 배포합니다.
이
az group create명령을 사용하여 구독에 새 리소스 그룹을 만듭니다.az group create \ --name "<resource-group-name>" \ --location "<location>"bicep 템플릿을 배포하려면
az deployment group create를 사용하십시오. 그런 다음adminUsername및adminPassword매개 변수에 대한 값을 입력하라는 메시지가 표시됩니다.az deployment group create \ --resource-group "<resource-group-name>" \ --template-file 'main.bicep'팁 (조언)
또는 미리 정의된 값이 있는 매개 변수 파일을 전달하는 옵션을 사용합니다
--parameters.az deployment group create \ --resource-group "<resource-group-name>" \ --template-file 'main.bicep' \ --parameters @main.parameters.json이 예제 JSON 파일은
clusteradmin값과P@ssw.rd값을 각각adminUsername및adminPassword매개 변수에 삽입합니다.{ "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", "contentVersion": "1.0.0.0", "parameters": { "adminUsername": { "value": "clusteradmin" }, "adminPassword": { "value": "P@ssw.rd" } } }계속 진행하기 전에 배포 작업이 완료되기를 기다립니다.
배포된 리소스 검토
리소스 그룹에 배포된 Azure DocumentDB 리소스를 나열합니다.
리소스 그룹의 리소스 목록을 가져오는 데 사용합니다
az resource list.az resource list \ --resource-group "<resource-group-name>" \ --namespace "Microsoft.DocumentDB" \ --resource-type "mongoClusters" \ --query "[].name" \ --output json예제 출력에서 형식
Microsoft.DocumentDB/mongoClusters이 있는 리소스를 찾습니다. 다음은 예상할 출력 형식의 예입니다.[ "msdocs-documentdb-example-cluster" ]
자원을 정리하세요
Azure DocumentDB 클러스터를 완료하면 더 많은 요금이 발생하지 않도록 만든 Azure 리소스를 삭제할 수 있습니다.
구독에서 리소스 그룹을 제거하는 데 사용합니다
az group delete.az group delete \ --name "<resource-group-name>" \ --yes \ --no-wait중요합니다
이 명령을 실행하기 전에 리소스가 영구적으로 삭제되므로 리소스가 더 이상 필요하지 않은지 확인합니다.