@@ -9,7 +9,10 @@ This script downloads, installs and launches cosmosdb-emulator.
99Uri for downloading the cosmosdb-emulator
1010
1111. PARAMETER StartParameters
12- Parameter with which to launch the cosmosdb-emulator
12+ Parameter with which to launch the cosmosdb-emulator\
13+
14+ . PARAMETER Emulator
15+ Exact path to Microsoft.Azure.Cosmos.Emulator.exe
1316
1417. PARAMETER Stage
1518Determines what part of the script to run. Has to be either Install or Launch
@@ -18,6 +21,7 @@ Determines what part of the script to run. Has to be either Install or Launch
1821Param (
1922 [string ] $EmulatorMsiUrl = " https://aka.ms/cosmosdb-emulator" ,
2023 [string ] $StartParameters ,
24+ [string ] $Emulator ,
2125 [Parameter (Mandatory = $True )]
2226 [ValidateSet (' Install' , ' Launch' )]
2327 [string ] $Stage
@@ -26,7 +30,11 @@ Param (
2630$targetDir = Join-Path $Env: Temp AzureCosmosEmulator
2731$logFile = Join-Path $Env: Temp log.txt
2832$productName = " Azure Cosmos DB Emulator"
29- $emulator = (Join-Path $targetDir (Join-Path $productName " Microsoft.Azure.Cosmos.Emulator.exe" ))
33+
34+ if ([string ]::IsNullOrEmpty($Emulator ))
35+ {
36+ $Emulator = (Join-Path $targetDir (Join-Path $productName " Microsoft.Azure.Cosmos.Emulator.exe" ))
37+ }
3038
3139if ($Stage -eq " Install" )
3240{
@@ -58,19 +66,19 @@ if ($Stage -eq "Install")
5866 }
5967
6068 Write-Host " Getting Cosmos DB Emulator Version"
61- $fileVersion = Get-ChildItem $emulator
62- Write-Host $emulator $fileVersion.VersionInfo
69+ $fileVersion = Get-ChildItem $Emulator
70+ Write-Host $Emulator $fileVersion.VersionInfo
6371}
6472
6573if ($Stage -eq " Launch" )
6674{
6775 Write-Host " Launching Cosmos DB Emulator"
68- if (! (Test-Path $emulator )) {
69- Write-Error " The emulator is not installed where expected at '$emulator '"
76+ if (! (Test-Path $Emulator )) {
77+ Write-Error " The emulator is not installed where expected at '$Emulator '"
7078 return
7179 }
7280
73- $process = Start-Process $emulator - ArgumentList " /getstatus" - PassThru - Wait
81+ $process = Start-Process $Emulator - ArgumentList " /getstatus" - PassThru - Wait
7482 switch ($process.ExitCode ) {
7583 1 {
7684 Write-Host " The emulator is already starting"
@@ -97,8 +105,8 @@ if ($Stage -eq "Launch")
97105 $argumentList = " /noexplorer /noui /enablepreview /disableratelimiting /enableaadauthentication"
98106 }
99107
100- Write-Host " Starting emulator process: $emulator $argumentList "
101- $process = Start-Process $emulator - ArgumentList $argumentList - ErrorAction Stop - PassThru
108+ Write-Host " Starting emulator process: $Emulator $argumentList "
109+ $process = Start-Process $Emulator - ArgumentList $argumentList - ErrorAction Stop - PassThru
102110 Write-Host " Emulator process started: $ ( $process.Name ) , $ ( $process.FileVersion ) "
103111
104112 $Timeout = 600
@@ -117,7 +125,7 @@ if ($Stage -eq "Launch")
117125 }
118126
119127 do {
120- $process = Start-Process $emulator - ArgumentList " /getstatus" - PassThru - Wait
128+ $process = Start-Process $Emulator - ArgumentList " /getstatus" - PassThru - Wait
121129 switch ($process.ExitCode ) {
122130 1 {
123131 Write-Host " The emulator is starting"
0 commit comments