Skip to content

Instantly share code, notes, and snippets.

@IlyaFinkelshteyn
Created September 18, 2017 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IlyaFinkelshteyn/764e85204f12859e87c1ff1faf9c631e to your computer and use it in GitHub Desktop.
Save IlyaFinkelshteyn/764e85204f12859e87c1ff1faf9c631e to your computer and use it in GitHub Desktop.
Invoke-WebRequest -Uri 'https://aka.ms/cosmosdb-emulator' -OutFile 'cosmos-db.msi'
cmd /c start /wait msiexec /i cosmos-db.msi /qn /quiet /norestart /log install.log
Set-Content -Value '"C:\Program Files\Azure Cosmos DB Emulator\CosmosDB.Emulator.exe" /NoUI /NoExplorer /NoFirewall' -Path .\startCosmosDb.cmd
Start-Process -FilePath .\startCosmosDb.cmd
$attempt = 0
$max = 3
while(!$client.Connected -and $attempt -lt $max) {
try {
$client = New-Object System.Net.Sockets.TcpClient([System.Net.Sockets.AddressFamily]::InterNetwork)
$attempt++; $client.Connect("127.0.0.1", 8081); write-host "CosmosDB started"
}
catch {
if($attempt -eq $max) {
write-host "CosmosDB was not started"; $client.Close(); return
}
[int]$sleepTime = 5*$attempt
write-host "CosmosDB is not started. Retry after $sleepTime seconds..."
sleep $sleepTime;
$client.Close()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment