Cosmos DB Emulator: Failed to get authorization headers for offers

It looks like 2.0.0 CosmosDB Emulator requires you to reset the data that's in it. That's the only thing that fixed it for me.

You can do that from the CosmosDB emulator icon

enter image description here

Once you reset, it will work. Also keep in mind that pre 2.0 SDKs won't work on the new emulator.


In my case, I had to uninstall / reinstall the emulator (you can download it from https://aka.ms/cosmosdb-emulator), then after a reboot I did a "Reset data..." in the emulator's context menu (as described by Nick), and afterwards it was working again.

Resetting the data alone did not do the trick in my case.

I found the following way to get it working again (Emulator Version 2.1.4.0 on Windows 10 Enterprise - Build 1803):

  1. Start the emulator so you're getting a systray icon. Wait until you get "Emulator started" message. Check after startup if the Emulator explorer is working. If it hangs (showing three dots animation forever), continue with step 2.
  2. Reset data: Via Systray, right click, context menu, select "Reset data...". Wait until the emulator came up ("Emulator started"). Continue with step 3.
  3. Shutdown the Emulator: Via Systray, right click, context menu, select "Exit"
  4. Reboot your PC
  5. After reboot, start the emulator (go to 1.). Now the Emulator explorer should work (you can create a collection via "New collection" to test it).

Notes:

  • "Reset data..." deletes the local Cosmos DB Emulator folder, then it stops and restarts the emulator service.

  • it seem to be important to start it before you start any VPN connection (e.g. the firm's VPN) - The emulator depends on the RegisteredIO APIs in addition to regular Winsockets so there can be undesired side effects with 3rd party software.

  • if you run the emulator on a laptop, it is recommended that you stop it before your computer enters sleep/hibernate mode. This is to ensure that the emulator’s data remains consistent and prevent you from resetting it often.

  • Since version 2.2.1, there is a new command line option /disablerio that will switch the emulator to work with regular Winsockets APIs. If you encounter any issues with VPNs or 3rd party software, you can try this switch. In a command prompt (admin shell), type:
    cd /d "%ProgramFiles%\Azure Cosmos DB Emulator"
    CosmosDB.Emulator.exe /disablerio

  • if you run into connect issues, check the CosmosDB emulator's SSL certificates.


Some details about the emulator

This is the directory the emulator is using:

C:\Users\[userid]\AppData\Local\CosmosDBEmulator

The application itself can be found here:

C:\Program Files\Azure Cosmos DB Emulator\Microsoft.Azure.Cosmos.Emulator.exe

While the emulator itself doesn't have many config options, there are 3 config files in the directory mentioned above: ComputeMachine.Config, Machine.Config and GatewayMachine.Config.

The CosmosDB team can help if you enable the trace log. Do the following:

To collect debugging traces, run the following commands from an administrative command prompt:

  1. cd /d "%ProgramFiles%\Azure Cosmos DB Emulator"
  2. CosmosDB.Emulator.exe /shutdown. Watch the system tray to make sure the program has shut down, it may take a minute. You can also just click Exit in the Azure Cosmos DB Emulator user interface.
  3. CosmosDB.Emulator.exe /starttraces
  4. CosmosDB.Emulator.exe
  5. Reproduce the problem. If Data Explorer is not working, you only need to wait for the browser to open for a few seconds to catch the error.
  6. CosmosDB.Emulator.exe /stoptraces
  7. Navigate to %ProgramFiles%\Azure Cosmos DB Emulator and find the docdbemulator_000001.etl file.
  8. Send the .etl file along with repro steps to [email protected] for debugging.

Update: I got response from the CosmosDB dev team, which I've included in this answer. Please let me also know via comments below this answer if you found out something. Let me note that usually this tool, which I use very often for developing CosmosDB solutions, is working fine.