I'm trying to make an Azure Function run with CosmosDB output binding.
The trigger is HTTP, the DB is defined with SQL API.
Here is my code:
[FunctionName("ProcessOrderCosmos")]
public static void Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequest req,
[CosmosDB(
databaseName: "myDB",
collectionName: "items",
ConnectionStringSetting = "CosmosDBConnection")]out Item item,
ILogger log)
{
string requestBody = new StreamReader(req.Body).ReadToEndAsync().Result;
item=JsonConvert.DeserializeObject<Item>(requestBody);
}
However, the function shows the following error:
PartitionKey extracted from document doesn't match the one specified in the header
What is the problem? Since I'm using the binding, I have no control over the payload sent to the server, and don't have access to the headers.
What am I missing?