Giter Club home page Giter Club logo

Getting exception BadRequestException: Cross partition query is required but disabled. Please set x-ms-documentdb-query-enablecrosspartition to true, specify x-ms-documentdb-partitionkey, or revise your query to avoid this exception. about aspnetcore.identity.documentdb HOT 8 CLOSED

codekoenig avatar codekoenig commented on June 8, 2024
Getting exception BadRequestException: Cross partition query is required but disabled. Please set x-ms-documentdb-query-enablecrosspartition to true, specify x-ms-documentdb-partitionkey, or revise your query to avoid this exception.

from aspnetcore.identity.documentdb.

Comments (8)

TheDarkCode avatar TheDarkCode commented on June 8, 2024 1

I'm going to try to put up my fork of this which addresses the partitioning issue within the next week or so. But you'll have lots of breaking changes since I changed all the naming conventions of classes and other properties to be more generic for Identity.

For now, you can just add the following parameter to each document query and recompile this project:
new FeedOptions { EnableCrossPartitionQuery = true }

from aspnetcore.identity.documentdb.

codekoenig avatar codekoenig commented on June 8, 2024

It seems you are using DocumentDb automatic partitioning which is unfortunately not yet supported with this provider (see #1) as I did not find a solution yet on how to do support this in an as generic as possible way. There needs to be a possibility to tell this provider how you want to have your data partitioned, and I don't want to force the user of this provider into any partitioning strategy defined by me (i.e. by e-mail TLD or something, that might not be the best solution for everyone).

Currently you have two options when you want to use this provider:

  • For users and roles, add an additional, not auto-partitioned collection to your DocumentDb. Depending on the load you expect on this collection, it might not be an option.
  • Fork this project and add the required code to support partitioning for your specific scenario. If you don't have to support a generic solution, it's pretty easy to implement (you know, pass the partition key on queries and so forth). If you need help on where to add the required bits, let me know.

Else, you'd have to wait until I come up with a generic solution that lets you configure this provider on how it should partition your data.

from aspnetcore.identity.documentdb.

codekoenig avatar codekoenig commented on June 8, 2024

As discussed, this behavior is as designed. Please track #1 to see progress on implementing support for partitioning.

from aspnetcore.identity.documentdb.

greg-dickie avatar greg-dickie commented on June 8, 2024

Sorry to bring up an old issue, but I'm working with your library and would like to add my own support for partitioning. I think I have it mostly working except when the FindByIdAsync method is called on the user store. I have my partition for users as the domain name of the email address and I can't think of a way to figure out what that would be based on the user id.

It also appears to me that you can't enable cross partition queries for RequestOptions so I have to supply the correct partition key.

Any thoughts on how I can solve this? I apologize if I'm going about this the wrong way, I'm new to Github and Cosmos DB and I'm learning as I go.

Thanks for any help you can give,
Greg

from aspnetcore.identity.documentdb.

codekoenig avatar codekoenig commented on June 8, 2024

@greg-dickie Yea, that's a huge problem. I'm thinking about how to tackle support for partitioning for a while now - see #1 - but it's very tricky because of how ASP.NET Identity works and you can end up with just knowing about the User ID and nothing else.

So actually you would have to have some information within the UserId that tells you which partition to use. Or you could use some lookup store where you cache/hold a mapping from UserId to it's partition (maybe in another DocumentDb Collection, in a Redis Cache, ...) - all of this would of course require a custom implementation.

What this all comes down to would be a custom implementation of ASP.NET Identity if one would want to generalize partitioning support -and that's pretty much out of scope :). Personally, I moved on from using ASP.NET Identity with Documentdb when auto partitioning is required - for an application I'm currently developing I store the users in Azure AD B2C only (instead of storing them in DocumentDb and using IdentityServer based on that user store).

from aspnetcore.identity.documentdb.

greg-dickie avatar greg-dickie commented on June 8, 2024

from aspnetcore.identity.documentdb.

Jeremywhiteley avatar Jeremywhiteley commented on June 8, 2024

I found this guide on how to set up Cosmos DB with Azure Ad B2C using a function app. I am surprised Microsoft hasn't given us more "how to examples" with this scenario. With 5g coming out, this is going to be big for cosmos DB.

https://github.com/adamhockemeyer/Azure-Functions---CosmosDB-ResourceToken-Broker

Wiki is here: https://github.com/adamhockemeyer/Azure-Functions---CosmosDB-ResourceToken-Broker/wiki

from aspnetcore.identity.documentdb.

scottkuhl avatar scottkuhl commented on June 8, 2024

For users and roles, add an additional, not auto-partitioned collection to your DocumentDb.

@codekoenig How exactly do you do that in Cosmos DB?

from aspnetcore.identity.documentdb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.