Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for C# SDK v3 #31

Closed
asleire opened this issue Apr 29, 2020 · 5 comments
Closed

Support for C# SDK v3 #31

asleire opened this issue Apr 29, 2020 · 5 comments

Comments

@asleire
Copy link
Contributor

asleire commented Apr 29, 2020

The C# SDK currently does not work with this CosmosDb server.
NuGet package: https://www.nuget.org/packages/Microsoft.Azure.Cosmos/

I discovered the following issues while attempting to make it work:

  • SDK can not be configured to ignore SSL validation errors. My workaround was using reflection to configure the SDK internals
  • Addresses endpoint as in Query to //addresses/?$resolveFor=dbs&$filter=protocol%20eq%20rntbd #29 is not implemented. Workaround is configuring the C# SDK to use Gateway mode.
  • Whenever an error occurs (>399 status code), the C# SDK expects a case sensitive message property with non-null value in the response body. Otherwise it will throw a NullReferenceException.
  • "Meta" / root endpoint must return certain data, otherwise SDK will throw a NullReferenceException. Additionally the queryEngineConfiguration property is required for querying to work.
  • The C# parses and validates the _rid property. In particular, it requires RID for collections to have a specific bit set to 1 (first bit of 5th byte)
  • A property on partitionKeyRanges is invalid, it is maxInclusive but should be maxExclusive
  • C# SDK sends boolean headers with a "True" value instead of "true", causing the server to not handle them as true
  • C# SDK will query partitionKeys using an "Incremental Feed". See A-IM header. Essentially it expects an etag when retrieving partition keys, and it expects a 302 status code once all keys have been received. Current behavior causes an infinite loop in the C# SDK

After forking this repo and applying fixes for the above I am able to successfully use this server with the C# SDK.

I noticed you have a current draft PR with some fixes for the Java SDK, which will fix some of the issues here. I can make a PR with the remaining fixes if you'd like

@nkzawa
Copy link
Contributor

nkzawa commented Apr 29, 2020

Thanks for the detailed report! They all are great findings 😮

Really appreciate it if you can make the PR. Feel free to reuse some code from #30 if needed.

@kirankumarkolli
Copy link

For emulator SSL the work-around is covered at https://docs.microsoft.com/en-us/azure/cosmos-db/local-emulator#running-on-mac-or-linux

@moredatapls
Copy link

@asleire regarding the SSL issue, you write that your

workaround was using reflection to configure the SDK internals

Could you explain how you disabled the SSL verification in the client? Thanks a lot!

@asleire
Copy link
Contributor Author

asleire commented Jul 11, 2020

@moredatapls
I wrote this method for creating a CosmosClient with SSL validation disabled: https://gist.github.com/asleire/73fda6b5e80ae4c85b2794470fb46257
It should work with Microsoft.Azure.Cosmos package version 3.6.0

@asleire
Copy link
Contributor Author

asleire commented Jul 11, 2020

I'll close this issue since my PR has been merged. I found more issues regarding advanced queries with the C# client, but basic usage works now

@asleire asleire closed this as completed Jul 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants