99 Write-Host "Target Dir: $targetDir"
1010 msiexec /a ${{ parameters.EmulatorMsiUrl }} TARGETDIR=$targetDir /qn | wait-process
1111 displayName: Download and Extract Public Cosmos DB Emulator
12+ - powershell : |
13+ Write-Host "Deleting Cosmos DB Emulator data"
14+ if (Test-Path $Env:LOCALAPPDATA\CosmosDbEmulator) { Remove-Item -Recurse -Force $Env:LOCALAPPDATA\CosmosDbEmulator }
15+ displayName: Delete Cosmos DB Emulator data
16+ - powershell : |
17+ Write-Host "Getting Cosmos DB Emulator Version"
18+ $ProductName = "Azure Cosmos DB Emulator"
19+ $Emulator = (Join-Path $env:temp (Join-Path $ProductName "Microsoft.Azure.Cosmos.Emulator.exe"))
20+ $fileVersion = Get-ChildItem $Emulator
21+ Write-Host $Emulator $fileVersion.VersionInfo
22+ displayName: Get Cosmos DB Emulator Version
1223 - powershell : |
1324 Write-Host "Launching Cosmos DB Emulator"
14- Import-Module "$env:temp\Azure Cosmos DB Emulator\PSModules\Microsoft.Azure.CosmosDB.Emulator"
15- Start-CosmosDbEmulator -NoUI ${{ parameters.StartParameters }}
25+ $ProductName = "Azure Cosmos DB Emulator"
26+ $Emulator = (Join-Path $env:temp (Join-Path $ProductName "Microsoft.Azure.Cosmos.Emulator.exe"))
27+ if (!(Test-Path $Emulator)) {
28+ Write-Error "The emulator is not installed where expected at '$Emulator'"
29+ return
30+ }
31+ $process = Start-Process $Emulator -ArgumentList "/getstatus" -PassThru -Wait
32+ switch ($process.ExitCode) {
33+ 1 {
34+ Write-Host "The emulator is already starting"
35+ return
36+ }
37+ 2 {
38+ Write-Host "The emulator is already running"
39+ return
40+ }
41+ 3 {
42+ Write-Host "The emulator is stopped"
43+ }
44+ default {
45+ Write-Host "Unrecognized exit code $process.ExitCode"
46+ return
47+ }
48+ }
49+ $argumentList = ""
50+ if (-not [string]::IsNullOrEmpty("${{ parameters.StartParameters }}")) {
51+ $argumentList += , "${{ parameters.StartParameters }}"
52+ } else {
53+ # Use the default params if none provided
54+ $argumentList = "/noexplorer /noui /enablepreview /disableratelimiting /enableaadauthentication"
55+ }
56+ Write-Host "Starting emulator process: $Emulator $argumentList"
57+ $process=Start-Process $Emulator -ArgumentList $argumentList -ErrorAction Stop -PassThru
58+ Write-Host "Emulator process started: $($process.Name), $($process.FileVersion)"
59+ $Timeout = 600
60+ $result="NotYetStarted"
61+ $complete = if ($Timeout -gt 0) {
62+ $start = [DateTimeOffset]::Now
63+ $stop = $start.AddSeconds($Timeout)
64+ {
65+ $result -eq "Running" -or [DateTimeOffset]::Now -ge $stop
66+ }
67+ }
68+ else {
69+ {
70+ $result -eq "Running"
71+ }
72+ }
73+ do {
74+ $process = Start-Process $Emulator -ArgumentList "/getstatus" -PassThru -Wait
75+ switch ($process.ExitCode) {
76+ 1 {
77+ Write-Host "The emulator is starting"
78+ }
79+ 2 {
80+ Write-Host "The emulator is running"
81+ $result="Running"
82+ return
83+ }
84+ 3 {
85+ Write-Host "The emulator is stopped"
86+ }
87+ default {
88+ Write-Host "Unrecognized exit code $process.ExitCode"
89+ }
90+ }
91+ Start-Sleep -Seconds 5
92+ }
93+ until ($complete.Invoke())
94+ Write-Error "The emulator failed to reach Running status within ${Timeout} seconds"
1695 displayName: Start Cosmos DB Emulator
0 commit comments