Skip to content

Commit cb52086

Browse files
Revert "[INTERNAL] CI: Fixes emulator set-up to leverage central SDK teams scripts (#4813)"
This reverts commit c69feae.
1 parent ca55727 commit cb52086

File tree

3 files changed

+67
-165
lines changed

3 files changed

+67
-165
lines changed

templates/Cosmos-Emulator.ps1

Lines changed: 0 additions & 151 deletions
This file was deleted.

templates/emulator-setup.yml

Lines changed: 67 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,69 @@
1-
parameters:
2-
EmulatorInstallPath: "$(Agent.HomeDirectory)/../../Program Files/Azure Cosmos DB Emulator/Microsoft.Azure.Cosmos.Emulator.exe"
3-
EmulatorMsiUrl: "https://aka.ms/cosmosdb-emulator"
4-
StartParameters: ''
1+
# File: templates/emulator-setup.yml
52

63
steps:
7-
- task: Powershell@2
8-
inputs:
9-
filePath: $(Build.SourcesDirectory)/templates/Cosmos-Emulator.ps1
10-
arguments: >
11-
-EmulatorMsiUrl "${{ parameters.EmulatorMsiUrl }}"
12-
-StartParameters "${{ parameters.StartParameters }}"
13-
-Emulator "${{ parameters.EmulatorInstallPath }}"
14-
-Stage "Launch"
15-
pwsh: true
16-
displayName: Launch Public Cosmos DB Emulator
4+
- pwsh: |
5+
Write-Host "Downloading Cosmos Emulator - $env:EMULATORMSIURL" -ForegroundColor green
6+
Invoke-WebRequest "$env:EMULATORMSIURL" -OutFile "$env:temp\azure-cosmosdb-emulator.msi"
7+
Write-Host "Finished Downloading Cosmos Emulator - $env:temp\azure-cosmosdb-emulator.msi" -ForegroundColor green
8+
dir "$env:temp"
9+
10+
function Remove-DirectoryIfExists {
11+
param ([string]$Path)
12+
13+
if (Test-Path -Path $Path -PathType Container) {
14+
Remove-Item -Path $Path -Recurse -Force
15+
Write-Output "Folder deleted: $Path"
16+
} else {
17+
Write-Output "Folder does not exist: $Path"
18+
}
19+
}
20+
21+
$lessMsiDir="$env:temp\lessmsi"
22+
$emulatorDir="$env:temp\Azure Cosmos DB Emulator\"
23+
24+
Remove-DirectoryIfExists -Path $lessMsiDir
25+
Remove-DirectoryIfExists -Path $emulatorDir
26+
27+
Expand-Archive -LiteralPath 'tools\lessmsi-v2.1.1.zip' -DestinationPath $lessMsiDir
28+
&"$env:temp\lessmsi\lessmsi.exe" x "$env:temp\azure-cosmosdb-emulator.msi" "$emulatorDir"
29+
30+
Add-MpPreference -ExclusionPath "$emulatorDir\SourceDir\Azure Cosmos DB Emulator"
31+
Add-MpPreference -ExclusionPath "$env:localappdata\CosmosDBEmulator"
32+
displayName: Downloading and Installing Cosmos DB Emulator
33+
failOnStderr: true
34+
errorActionPreference: stop
35+
- pwsh: |
36+
Write-Host "Starting Cosmos DB Emulator" -ForegroundColor green
37+
Import-Module "$env:temp\Azure Cosmos DB Emulator\SourceDir\Azure Cosmos DB Emulator\PSModules\Microsoft.Azure.CosmosDB.Emulator"
38+
Get-Item env:* | Sort-Object -Property Name
39+
40+
for ($j=0; $j -lt 3; $j++) {
41+
Write-Host "Attempt $j"
42+
Start-Process "$env:temp\Azure Cosmos DB Emulator\SourceDir\Azure Cosmos DB Emulator\CosmosDB.Emulator.exe" "/NoExplorer /NoUI /DisableRateLimiting /PartitionCount=10 /Consistency=Strong /EnablePreview /EnableSqlComputeEndpoint" -Verb RunAs
43+
for ($i=0; $i -lt (3+2*$j); $i++) {
44+
$status = Get-CosmosDbEmulatorStatus
45+
Write-Host "Cosmos DB Emulator Status: $status"
46+
if ($status -ne "Running") {
47+
sleep 30;
48+
}
49+
else {
50+
break;
51+
}
52+
}
53+
if ($status -ne "Running") {
54+
Write-Host "Shutting down and restarting"
55+
Start-Process "$env:temp\Azure Cosmos DB Emulator\SourceDir\Azure Cosmos DB Emulator\CosmosDB.Emulator.exe" "/Shutdown" -Verb RunAs
56+
sleep 30;
57+
}
58+
else {
59+
break;
60+
}
61+
}
62+
63+
if ($status -ne "Running") {
64+
Write-Error "Emulator failed to start"
65+
}
66+
67+
displayName: Waiting for Cosmos DB Emulator status
68+
failOnStderr: true
69+
errorActionPreference: stop

tools/lessmsi-v2.1.1.zip

652 KB
Binary file not shown.

0 commit comments

Comments
 (0)