We are trying to use Azure Storage Emulator and Azure CosmosDB Emulator for our local development as well as unit testing as part of CI / CD builds. Here is the main link with details on these emulators: https://docs.microsoft.com/en-us/azure/cosmos-db/local-emulator
As part of this effort, we need some way to start and stop both the emulators. We have tried running on Docker, but it has its own issues due to anti-virus interventions etc, so I don't want to talk about that option in this post. This is our main requirement - to start the emulators during machine reboot / startup. We were able to get this working in case of Azure Storage Emulator just by calling the approriate command to start the emulator via Windows Task Scheduler, it was super easy. So we tried the same approach with CosmosDB Emulator, but it just fails with "Catastrphic failure (0x8000FFFF)" error without much details to troubleshoot the problem. This is on a Windows Server 2016 Standard machine, but I get the same result on my Windows 10 Enterprise machine as well.
Since then I tried few other options as below:
This works when I manually run the batch file, but not via task scheduler.
Same approach using Powershell and same results as above.
Finally I created a windows service using Topshelf which again works when running using visual studio or debugging code, but not when I install the service and run it within services console.
Is there any other option to get this working?
@sharushetty Thanks for the feedback. We are actively investigating and will get back to you soon.
Hello @sharushetty,
Please allow me to introduce myself. I'm dev owner of the Cosmos DB Emulator. Thanks for writing.
To start the Emulator via the task scheduler, try using this command line option: /noui
. Please also ensure that the task runs with highest privileges under an account that belongs to the Administrators group.
I defined such a task just now that runs when I log in to my Windows 10 dev box. It runs this command line under my domain account which belongs to the local Administrators group:
"C:\Program Files\Azure Cosmos DB Emulator\CosmosDB.Emulator.exe" /noui
I confirmed that when I ran this task:
Without the /noui
option I saw the error you saw: E_UNEXPECTED (0x8000FFFF), Catastrophic failure.
With the /noui
option, the Emulator started correctly (without the task bar icon and without opening the data explorer as expected) and that I could use the data explorer to create documents.
Please give this a try and let us know how it goes. I'm here to help, if need be.
Perfect, that did the magic!! Appreciate your quick response with this. Thanks a lot @David-Noble-at-work.
Hello @David-Noble-at-work,
While the main problem with not being able to start the cosmosdb emulator via Windows Task Scheduler got resolved, I do see one issue which may or may not be related to the emulator, but I just wanted to run it through you once to make sure I'm not missing something. When I start the task in Task Manager, the task "Status" stays at "Running" forever and doesn't return to "Ready". I tried refresh option as put down in this link, but that didn't help. I have turned on both "Stop the task if it runs longer than: 1 hour" and "If the running task does not end when requested, force it to stop" options hoping that they might help in getting the status back to "Ready". Just wondering if there is some code within cosmosdb emulator startup that is making the task to stay running, say something to the effect of "Console.ReadLine()" for example?
@sharushetty We will now proceed to close this thread. If there are further questions regarding this matter, please reopen it and we will gladly continue the discussion.
@sharushetty Sorry I didn't see your follow-up question earlier. To make the task status change from Running to Ready before the Emulator is finished you can run it from a script that starts the Emulator without waiting for it to exit. You might for example run it from a Start.cmd script that contains this single line of code:
"C:\Program Files\Azure Cosmos DB Emulator\CosmosDB.Emulator.exe" /noui
You might already have figured this out. Thanks for using the Cosmos DB:)
@David-Noble-at-work, thank you.
Is there a way to have the emulator start when the system boots? We're using TeamCity, and the build agent runs under the system account, and so most of the time there is nobody logged in.
I tried to get it started by creating a service with sc.exe, but I couldn't reach a point where it worked.
Can someone explain the difference between
C:\Program Files\Azure Cosmos DB EmulatorCosmosDB.Emulator.exe and
C:\Program Files\Azure Cosmos DB Emulator\Microsoft.Azure.Cosmos.Emulator.exe?
Which version of the Emulator are you running? I currently have v.2.1.3 installed.
Not sure how you got that view above showing version number and uninstall but this is what I have ...
Navigate to Start > Settings:
Then select Apps and Features:
Followed by typing Cosmos
into the filter and clicking on Cosmos to reveal the currently installed version:
Most helpful comment
Hello @sharushetty,
Please allow me to introduce myself. I'm dev owner of the Cosmos DB Emulator. Thanks for writing.
To start the Emulator via the task scheduler, try using this command line option:
/noui
. Please also ensure that the task runs with highest privileges under an account that belongs to the Administrators group.I defined such a task just now that runs when I log in to my Windows 10 dev box. It runs this command line under my domain account which belongs to the local Administrators group:
I confirmed that when I ran this task:
Without the
/noui
option I saw the error you saw: E_UNEXPECTED (0x8000FFFF), Catastrophic failure.With the
/noui
option, the Emulator started correctly (without the task bar icon and without opening the data explorer as expected) and that I could use the data explorer to create documents.Please give this a try and let us know how it goes. I'm here to help, if need be.