MicrosoftDocs / azure-docs

Open source documentation of Microsoft Azure
https://docs.microsoft.com/azure
Creative Commons Attribution 4.0 International
10.08k stars 21.12k forks source link

PartitionKey is required for input binding #40810

Open brandonh-msft opened 4 years ago

brandonh-msft commented 4 years ago

Using the single-doc sample shown here will result in an HTTP 500 saying PartitionKey is required.

I would advise re-assessment of all usages of the Cosmos binding shown in this doc.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

brandonh-msft commented 4 years ago

cc @sarah-aly

mike-urnun-msft commented 4 years ago

@brandonh-msft Thank you for your feedback! We have assigned this issue to the author to review further and take the right course of action.

lokijota commented 4 years ago

+1. Agreed with @brandonh-msft .

mcollier commented 4 years ago

It appears that the input binding examples have moved to https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-cosmosdb-v2-input?tabs=csharp. The examples include the partition key, and a note indicating that if the collection is partioned, then a partition key is required.

Is there more to do on this feedback? @mike-urnun-msft @craigshoemaker

lokijota commented 4 years ago

So actually I've just tried it just yesterday. I have a CosmosDb collection partitioned on /nameOfField, and no-matter what I do in an output binding:

It always inserts the new record.

Interestingly, when inserting with LogicApps, there has to be an header with the VALUE of the partition key (not the path), and it has to be the same as the one on the request payload. As to functions, I have no idea how this works.

Also the documentation page says: "PartitionKey | When CreateIfNotExists is true, it defines the partition key path for the created collection." but this could be made clearer. I'm seeing several examples on the web and even in a book where the pk value is passed here instead of the "key path". For example:

https://books.google.de/books?id=KB2IDwAAQBAJ&pg=PA43&lpg=PA43&dq=CosmosDB+output+binding&source=bl&ots=AXr_QtltBw&sig=ACfU3U1FOIgp_oryPNkwqG03lK9kdjHzpA&hl=en&sa=X&ved=2ahUKEwjIwoegk6rpAhUQQ0EAHYLYCkgQ6AEwF3oECBwQAQ#v=onepage&q=CosmosDB%20output%20binding&f=false

and

https://dontcodetired.com/blog/post/Writing-Azure-Cosmos-DB-Data-from-Azure-Functions

cachai2 commented 3 years ago

reassign: @cachai2 followup with CosmosDB