question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PartitionKey has fewer components than defined the collection resource. - On Azure not Local

See original GitHub issue

Describe the bug Performing a query similar to the below on a set of records. Container’s partition key is /pk . Documents have been stored as having PartitionKey.None (its a very small container). Query is performed using PartitionKey.None:

            QueryDefinition query = new QueryDefinition("SELECT TOP 1 h.slug FROM h WHERE ARRAY_CONTAINS(h.knownDomains, @domain)")
                                        .WithParameter("@domain", domain);
            QueryRequestOptions queryOptions = new QueryRequestOptions()
            {
                MaxItemCount = 1,
              PartitionKey = PartitionKey.None
            };

This code works in local debugging in Debug or Release modes. When deployed to Azure Functions, the behavior changes and the following exception is encountered: PartitionKey has fewer components than defined the collection resource.

I have changed deployment methods, suspecting nuget package differences but did not solve.

Expected behavior Identical functionality in local and on Azure, for PartitionKey.None to be accepted.

Actual behavior PartitionKey has fewer components than defined the collection resource encountered in Azure Functions, not in local.

Environment summary SDK Version: Microsoft.Azure.Cosmos versions 3.14.0 and 3.15.0 OS Version: Windows 10 local development, Azure Functions v3

Additional context Work Around: Remove Partition Key in query.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
adrianagdicommented, Aug 11, 2022

We recently encountered this issue using Microsoft.Azure.Cosmos 3.29.0: queries with Partition.None worked correctly on local development environment and failed when deployed in Azure with error: ‘PartitionKey has fewer components than defined the collection resource.’

Turns out the App Service we were running this code on had Platform = 32 Bit, while on local we were running on 64 Bit.

We solved the problem by setting the Azure App Service Platform to 64 Bit.

(The error also reproduced on the local development environment when debugging using x86 solution platform)

1reaction
dustensalinascommented, Dec 3, 2020

Will replicate and inform. Appreciated.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to resolve : Cosmos DB x-ms-partitionkey Error
... to resolve the error "The partition key supplied in x-ms-partitionkey header has fewer components than defined in the the collection" ...
Read more >
Error -The partition key supplied in x-ms-partitionkey ...
I've created a database and a collection. When creating the collection, the partition key was a required field so I used 'Date' field...
Read more >
Why does a Cosmos DB REST API query require ...
I've created a database and a collection. When creating the collection, the partition key was a required field and the hint suggested that ......
Read more >
Adding new documents to Cosmos DB with null as a ...
When you supply a Partition Key for a specific collection, and some entries ... header has fewer components than defined in the collection....
Read more >
Issues with creating new Cosmos DB documents with Logic App
One part was to create order documents in a Cosmos DB using a Logic App. ... header has fewer components than defined in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found