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
2312 - powershell : |
2413 Write-Host "Launching Cosmos DB Emulator"
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-
32- $process = Start-Process $Emulator -ArgumentList "/getstatus" -PassThru -Wait
33-
34- switch ($process.ExitCode) {
35- 1 {
36- Write-Host "The emulator is already starting"
37- return
38- }
39- 2 {
40- Write-Host "The emulator is already running"
41- return
42- }
43- 3 {
44- Write-Host "The emulator is stopped"
45- }
46- default {
47- Write-Host "Unrecognized exit code $process.ExitCode"
48- return
49- }
50- }
51-
52- $argumentList = ""
53- if (-not [string]::IsNullOrEmpty("${{ parameters.StartParameters }}")) {
54- $argumentList += , "${{ parameters.StartParameters }}"
55- }
56-
57- Write-Host "Starting emulator process: $Emulator $argumentList"
58- $process=Start-Process $Emulator -ArgumentList $argumentList -ErrorAction Stop -PassThru
59- Write-Host "Emulator process started: $($process.Name), $($process.FileVersion)"
60- $Timeout = 600
61- $result="NotYetStarted"
62- $complete = if ($Timeout -gt 0) {
63- $start = [DateTimeOffset]::Now
64- $stop = $start.AddSeconds($Timeout)
65- {
66- $result -eq "Running" -or [DateTimeOffset]::Now -ge $stop
67- }
68- }
69- else {
70- {
71- $result -eq "Running"
72- }
73- }
74-
75- do {
76- $process = Start-Process $Emulator -ArgumentList "/getstatus" -PassThru -Wait
77-
78- switch ($process.ExitCode) {
79- 1 {
80- Write-Host "The emulator is starting"
81- }
82- 2 {
83- Write-Host "The emulator is running"
84- $result="Running"
85- return
86- }
87- 3 {
88- Write-Host "The emulator is stopped"
89- }
90- default {
91- Write-Host "Unrecognized exit code $process.ExitCode"
92- }
93- }
94-
95- Start-Sleep -Seconds 5
96- }
97- until ($complete.Invoke())
98-
99- Write-Error "The emulator failed to reach Running status within ${Timeout} seconds"
14+ Import-Module "$env:temp\Azure Cosmos DB Emulator\PSModules\Microsoft.Azure.CosmosDB.Emulator"
15+ Start-CosmosDbEmulator -NoUI ${{ parameters.StartParameters }}
10016 displayName: Start Cosmos DB Emulator
0 commit comments