Azure / azure-cosmos-dotnet-v3

.NET SDK for Azure Cosmos DB for the core SQL API
MIT License
743 stars 496 forks source link

All releases after 3.24.0 broken with Azure? Getting "Invalid API version. Ensure a valid x-ms-version header value is passed." #3170

Closed keystroke closed 2 years ago

keystroke commented 2 years ago

We are continuously addressing and improving the SDK, if possible, make sure the problem persist in the latest SDK version.

Describe the bug

We are using the latest release of the nuget 3.26.1, it sets a version header:

x-ms-version: 2019-10-14

This works with the emulator but when using a newly-created cosmos account from Azure, it fails with an error:

exited with exit code: -532462766 Unhandled exception. Microsoft.Azure.Cosmos.CosmosException : Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: 3482fde7-db22-4fc3-a1ee-377363428346; Reason: (Invalid API version. Ensure a valid x-ms-version header value is passed. Please update to the latest version of Azure Cosmos DB SDK.

ActivityId: 3482fde7-db22-4fc3-a1ee-377363428346, Microsoft.Azure.Documents.Common/2.14.0, Windows/10.0.17763 cosmos-netstandard-sdk/3.24.1); at Microsoft.Azure.Cosmos.GatewayStoreClient.ParseResponseAsync(HttpResponseMessage responseMessage, JsonSerializerSettings serializerSettings, DocumentServiceRequest request) at Microsoft.Azure.Cosmos.GatewayAccountReader.GetDatabaseAccountAsync(Uri serviceEndpoint) at Microsoft.Azure.Cosmos.Routing.GlobalEndpointManager.GetAccountPropertiesHelper.GetAndUpdateAccountPropertiesAsync(Uri endpoint)

The support page indicates this is not a supported version with Azure: https://docs.microsoft.com/en-us/rest/api/cosmos-db/#supported-rest-api-versions

Version | Change introduced | Retirement date -- | -- | -- 2018-12-31 | Partitioned collections automatic migration |   2018-09-17 | Composite and additional spatial indexing |   2018-08-31 | Dynamic collection scaling improvements |   2018-06-18 | Multi-region write support |   2017-11-15 | Multi-region Strong Consistency |   2017-05-03 | Large partition key |   2017-02-22 | Consistent prefix |   2017-01-19 | Lowered minimum throughput for partitioned collections to 2500 RU/s |   2016-07-11 | Change feed |   2015-12-16 | Partitioned collections |   2015-08-06 | Upsert |   2015-06-03 | Order By support |   2015-04-08 | DocumentDB general availability (now part of Azure Cosmos DB) |   2014-08-21 | DocumentDB public preview (now part of Azure Cosmos DB) | February 29th, 2016

To Reproduce Steps to reproduce the behavior. If you can include code snippets or links to repositories containing a repro of the issue that can helps us in detecting the scenario it would speed up the resolution.

Expected behavior A clear and concise description of what you expected to happen.

Actual behavior Provide a description of the actual behavior observed.

Environment summary SDK Version: OS Version (e.g. Windows, Linux, MacOSX)

Additional context Add any other context about the problem here (for example, complete stack traces or logs).

keystroke commented 2 years ago

I am seeing all the recent releases of the SDK are using this version, so not sure why it's being rejected by Azure cosmos DB we just created. Is there some configuration somewhere that sets the allowed version?

keystroke commented 2 years ago

I see this commit is what introduced the change?

https://github.com/Azure/azure-cosmos-dotnet-v3/pull/3015

keystroke commented 2 years ago

I have confirmed that release 3.24.0 is working with Azure! It sets the version header as "x-ms-version: 2018-12-31" which is working!

keystroke commented 2 years ago

This was tested against a newly-created cosmosDB in Azure. Is there something to configure to allow it to support the newer "2019-10-14" version?

keystroke commented 2 years ago

Investigating more, "x-ms-version: 2019-10-14" should be working with Azure. Likely issue with stale binaries / config routing to emulator that was rejecting the newer version. Will re-open if repro.