Azure Cosmos DB 에뮬레이터 빌드 작업을 사용하여 Azure DevOps에서 CI/CD 파이프라인 설정

적용 대상: NoSQL MongoDB Cassandra Gremlin 테이블

참고 항목

2022년 4월 1일에 Windows 2016 호스트 러너가 완전히 제거되었기 때문에 Azure DevOps에서 빌드 작업과 함께 Azure Cosmos DB 에뮬레이터를 사용하는 이 방법은 더 이상 지원되지 않습니다. 적극적으로 대체 솔루션에 노력하고 있습니다. 한편 아래 지침에 따라 "windows-2019" 에이전트 유형을 사용할 때 미리 설치된 Azure Cosmos DB 에뮬레이터를 활용할 수 있습니다.

Azure Cosmos DB 에뮬레이터는 개발 목적으로 Azure Cosmos DB 서비스를 에뮬레이트하는 로컬 환경을 제공합니다. 이 에뮬레이터를 사용하면 Azure 구독을 구입하거나 비용을 발생시키지 않고도 로컬에서 애플리케이션을 테스트할 수 있습니다.

Emulator에 대한 PowerShell 작업

Azure Cosmos DB 에뮬레이터를 시작하는 일반적인 PowerShell 기반 작업은 다음과 같이 스크립트할 수 있습니다.

"windows-2019" 에이전트 유형을 선택하는 작업 구성의 예입니다. Screenshot of the job configuration using windows-2019

에뮬레이터를 시작하는 데 필요한 PowerShell 스크립트를 실행하는 작업의 예입니다.

Screenshot executing the powershell script to start the emulator


# Write your PowerShell commands here.

dir "C:\Program Files\Azure Cosmos DB Emulator\"

Import-Module "$env:ProgramFiles\Azure Cosmos DB Emulator\PSModules\Microsoft.Azure.CosmosDB.Emulator"

$startEmulatorCmd = "Start-CosmosDbEmulator -NoFirewall -NoUI"
Write-Host $startEmulatorCmd
Invoke-Expression -Command $startEmulatorCmd

# Pipe an emulator info object to the output stream

$Emulator = Get-Item "$env:ProgramFiles\Azure Cosmos DB Emulator\Microsoft.Azure.Cosmos.Emulator.exe"
$IPAddress = Get-NetIPAddress -AddressFamily IPV4 -AddressState Preferred -PrefixOrigin Manual | Select-Object IPAddress

New-Object PSObject @{
Emulator = $Emulator.BaseName
Version = $Emulator.VersionInfo.ProductVersion
Endpoint = @($(hostname), $IPAddress.IPAddress) | ForEach-Object { "https://${_}:8081/" }
MongoDBEndpoint = @($(hostname), $IPAddress.IPAddress) | ForEach-Object { "mongodb://${_}:10255/" }
CassandraEndpoint = @($(hostname), $IPAddress.IPAddress) | ForEach-Object { "tcp://${_}:10350/" }
GremlinEndpoint = @($(hostname), $IPAddress.IPAddress) | ForEach-Object { "http://${_}:8901/" }
TableEndpoint = @($(hostname), $IPAddress.IPAddress) | ForEach-Object { "https://${_}:8902/" }
IPAddress = $IPAddress.IPAddress
}

또한 Azure Cosmos DB 에뮬레이터가 미리 설치되어 있지 않은 에이전트를 사용해야 하는 경우 고유한 자체 호스팅 Windows 에이전트를 빌드하는 옵션이 있습니다. 자체 호스팅 에이전트에서는 ‘curl’ 또는 ‘wget’을 사용하여 https://aka.ms/cosmosdb-emulator에서 최신 에뮬레이터의 MSI 패키지를 다운로드한 다음, ‘msiexec’를 사용하여 ‘무인’ 설치할 수 있습니다. 설치 후 위와 비슷한 PowerShell 스크립트를 실행하여 에뮬레이터를 시작할 수 있습니다.

다음 단계

로컬 개발 및 테스트에 에뮬레이터를 사용하는 방법을 자세히 알아보려면 로컬 개발 및 테스트를 위해 Azure Cosmos DB 에뮬레이터 사용을 참조하세요.

에뮬레이터 TLS/SSL 인증서를 내보내려면 Java, Python 및 Node.js에서 사용할 Azure Cosmos DB 에뮬레이터 인증서 내보내기를 참조하세요.