Azure / azure-cosmos-db-emulator-docker

This repo serves as hub for managing issues, gathering feedback, and having discussions regarding the Cosmos DB Emulator Docker.
https://learn.microsoft.com/en-us/azure/cosmos-db/how-to-develop-emulator?tabs=docker-linux%2Ccsharp&pivots=api-nosql
MIT License
149 stars 45 forks source link

Unable to use Data Explorer with Windows Emulator and AllowNetworkAccess #89

Open andyvanosdale opened 6 months ago

andyvanosdale commented 6 months ago

Describe the bug Using the v2.14.16 Windows Emulator (msi), I am using the /AllowNetworkAccess switch to allow for outside access to the emulator. Using this switch, it requires an explicit key (either through /Key or /KeyFile). When setting through either option, the Data Explorer does not work and provides this error:

Error while refreshing databases: The input authorization token can't serve the request. The wrong key is being used or the expected payload is not built as per the protocol. For more info: https://aka.ms/cosmosdb-tsg-unauthorized. Server used the following payload to sign: 'get
dbs

wed, 31 jan 2024 07:49:53 gmt

'
ActivityId: 5a1d28e0-98b7-41cc-a7d7-1b0076cafc75, Microsoft.Azure.Documents.Common/2.14.0

These are the commands I have used to start up the emulator:

'C:\Program Files\Azure Cosmos DB Emulator\Microsoft.Azure.Cosmos.Emulator.exe' /AllowNetworkAccess /KeyFile='C:\Users\Andy\keyfile.key'

'C:\Program Files\Azure Cosmos DB Emulator\Microsoft.Azure.Cosmos.Emulator.exe' /AllowNetworkAccess /Key=zJPOQ39FTi7nzAWjikIADhDL2dUJaxLC1BrjqwZPV083pKJLgfzeOSugQbQakSbhRyIkYj/1s983kWYfeNeGWw==

To Reproduce Steps to reproduce the behavior:

  1. Install Windows 11 ARM
  2. Install Cosmos DB Windows Emulator v2.14.16
  3. Start the Cosmos DB Emulator with /AllowNetworkAccess and provide a key through either /Key or /KeyFile. a. Use /GenKeyFile to create a key
  4. Once started, open Data Explorer a. Note that the Primary Key does not match the key provided in step 3
  5. Click Explorer on the left toolbar
  6. See error

Expected behavior I can access the data explorer to view data and write and execute queries.

Screenshots

Screenshot 2024-01-31 at 08 48 46 Screenshot 2024-01-31 at 08 46 59 Screenshot 2024-01-31 at 08 48 02

Desktop:

amanrao23 commented 6 months ago

Hi @andyvanosdale, instead of creating a new key, could you try again using the default emulator key?

Key:C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==

andyvanosdale commented 3 months ago

It looks like using the default emulator key works! Thank you, @amanrao23!

I would love to see this fixed where the key we provide via /Key or /KeyFile works with the Data Explorer since we have to provide a key when using /AllowNetworkAccess.