Search code examples
azureazure-cosmosdbazure-emulator

Azure Cosmos DB Emulator: Unauthorized after upgrate to 2.9.2


I upgraded Azure Cosmos DB Emulator to 2.9.2

Before 2.9.2 works like a charm but now, leaving out that I lost the data but that was expected (and I'm not complain), in the Explorer section I got this two errors

Error while querying offers: {"code":401,"body":{"code":"Unauthorized","message":"The input authorization token can't serve the request. Please check that the expected payload is built as per the protocol, and check the key being used. Server used the following payload to sign: 'get\noffers\n\nfri, MYDATE \n\n'\r\nActivityId: MYID, Microsoft.Azure.Documents.Common/2.9.2"},"headers":{"access-control-allow-credentials":"true","access-control-allow-origin":"","content-location":"https://localhost:8080/offers","content-type":"application/json","date":"MYDATE","server":"Microsoft-HTTPAPI/2.0","transfer-encoding":"chunked","x-ms-activity-id":"MYID","x-ms-gatewayversion":"version=2.9.2","x-ms-throttle-retry-count":0,"x-ms-throttle-retry-wait-time-ms":0},"activityId":"MYID"}

And this:

Error while refreshing databases: {"code":401,"body":{"code":"Unauthorized","message":"The input authorization token can't serve the request. Please check that the expected payload is built as per the protocol, and check the key being used. Server used the following payload to sign: 'get\noffers\n\nfri, MYDATE \n\n'\r\nActivityId: MYID, Microsoft.Azure.Documents.Common/2.9.2"},"headers":{"access-control-allow-credentials":"true","access-control-allow-origin":"","content-location":"https://localhost:8080/offers","content-type":"application/json","date":"MYDATE","server":"Microsoft-HTTPAPI/2.0","transfer-encoding":"chunked","x-ms-activity-id":"MYID","x-ms-gatewayversion":"version=2.9.2","x-ms-throttle-retry-count":0,"x-ms-throttle-retry-wait-time-ms":0},"activityId":"MYID"}

If I try to create a new database:

Error while creating database asd: {"code":401,"body":{"code":"Unauthorized","message":"The input authorization token can't serve the request. Please check that the expected payload is built as per the protocol, and check the key being used. Server used the following payload to sign: 'post\ndbs\n\n"MYDATE2" \n\n'\r\nActivityId:MYID2, Microsoft.Azure.Documents.Common/2.9.2"},"headers":{"access-control-allow-credentials":"true","access-control-allow-origin":"https://localhost:8080","access-control-expose-headers":"Access-Control-Allow-Origin,Access-Control-Allow-Credentials,Content-Type,x-ms-activity-id,x-ms-gatewayversion","content-type":"application/json","date":"MYDATE2 GMT","server":"Microsoft-HTTPAPI/2.0","transfer-encoding":"chunked","x-ms-activity-id":"MYID2","x-ms-gatewayversion":"version=2.9.2","x-ms-throttle-retry-count":0,"x-ms-throttle-retry-wait-time-ms":0},"activityId":"MYID2"}

I tried the answers from this similar thread Cosmos DB Emulator: Failed to get authorization headers for offers but I got nothing

MYID, MYID2, MYDATE and MYDATE2 are just placeholders, which I changed from the original values in my setup.

UPDATE
Here the SDK's error

Source:
System.Private.CoreLib / Microsoft.Azure.DocumentDB.Core

Message:

The input authorization token can't serve the request. Please check that the expected payload is built as per the protocol, and check the key being used. Server used the following payload to sign: 'get

mon, 02 mar 2020 11:01:04 gmt

' ActivityId: b6a56fc2-093d-4154-a4d6-d64ca08d167d, Microsoft.Azure.Documents.Common/2.9.2, Windows/6.3.9600 documentdb-netcore-sdk/2.6.0


Solution

  • I run the emulator with this parameters

    /AllowNetworkAccess /KeyFile=generatedKey /NoFirewall /Port=8080

    So...is the key stored inside the file "generatedKey" (generated with parameter /GenFileKey) that causing all my troubles!

    I changed the key stored in the file with the default key and works again!