How to get CosmosDB Emulator to automatically start upon machine startup / reboot

4

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 appropriate 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 "Catastrophic 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:

  1. Created a batch file with below command and run it via task scheduler: start /d "C:\Program Files\Azure Cosmos DB Emulator" CosmosDB.Emulator.exe

This works when I manually run the batch file, but not via task scheduler.

  1. Same approach using PowerShell and same results as above.

  2. 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.

We have tried with different user accounts, using ones with admin rights as well. I had missed to add the below detail in my original post:

The CosmosDB emulator will start if run manually by either me or my team members, but when it is invoked by the task scheduler the following error is written to the system log

The application-specific permission settings do not grant Local Activation permission for the COM Server application with CLSID {D63B10C5-BB46-4990-A94F-xxxxxxxxxxxx} and APPID {9CA88EE3-ACB7-47C8-AFC4-xxxxxxxxxxxx} to the user {Damain}{UserName} SID (S-1-5-21-174494438-4207865126-xxxxxxxxx-xxxxx) from address LocalHost (Using LRPC) running in the application container Unavailable SID (Unavailable). This security permission can be modified using the Component Services administrative tool.

Is there any other option to get this working?

azure
asked on Stack Overflow May 2, 2018 by Sharath • edited May 2, 2018 by Sharath

2 Answers

5

Posting the answer from David Noble below just so others can make use of it:

GitHub issue #7990

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.

answered on Stack Overflow May 3, 2018 by Sharath • edited Nov 5, 2018 by nulltoken
0

I did it by opening the file location of the CosmosDB shortcut on the start menu, copying the shortcut in that folder and pasting it to:

C:\Users\<user name>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

The UI works as expected.

answered on Stack Overflow Jan 20, 2020 by samneric

User contributions licensed under CC BY-SA 3.0