question

DavidLeek-4950 avatar image
0 Votes"
DavidLeek-4950 asked DavidLeek-4950 commented

Logic Apps and CosmosDB - Partition Key Troubles

Hello and thanks for reading!

I am trying to migrate from an Azure Table Storage instance to CosmosDB as the backing store for my logic app. The logic app is a webhook from Azure DevOps that records selected release information into a table. I've set up a Create or Update Document with proper connector. Right now I'm stuck on an error whereby regardless of how I massage the values I'm unable to get past "PartitionKey extracted from document doesn't match the one specified in the header".

10226-2020-06-17-10-54-02-logic-app-run-microsoft-azure.png

As you can see from the image, the values match. I've tried multiple iterations of this with different quotations, hard coding the values, going to the code view and pasting the same value in each key. Unfortunately, there is no way to determine the value the server thinks it is seeing, so the error message isn't terribly helpful.

Many of the answers I've found online reference making sure that the PartitionKey matches the one set for the collection, however this option doesn't appear anywhere in the current interface. So I'm stumped on how to proceed from here.

[As a side note, I'm not actually intending to use 'staging' as a partition value, I'm just reducing the complexity as far as possible to get it to work then trying to move up from there.]

azure-logic-appsazure-cosmos-db
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

SamaraSoucy-MSFT avatar image
0 Votes"
SamaraSoucy-MSFT answered DavidLeek-4950 commented

I can't tell for sure without knowing how your Cosmos container is setup, but my suspicion is that the partition key set in Cosmos is not the "PartitionKey" property.

For example, I could set the partition key to the project Id in Cosmos.
10723-2020-06-25-14-55-51-sasoucycosmos-data-explorer-mi.png

And then if I match the key value in Logic Apps to the "PartitionKey" property, it will throw the error:
10761-2020-06-25-17-25-48-logic-app-run-microsoft-azure.png

If you've confirmed that the partition key in Cosmos matches the property, please let me know so I can investigate further.


· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello, and thank you for your response.

I'm certain you are right, as that is the conclusion I arrived at. However, as mentioned in my initial response, I can't figure out where to set the partition key in Azure. I'm not sure if I'm looking in the wrong place or what the issue is. In my Data Explorer that setting isn't present.

10763-cosmosdataexplorerinterface.png

I'd appreciate any assistance in guiding me to this setting in the Table API interface as I have not been able to find any current documentation doing so.

0 Votes 0 ·

The key here is that you are using the Table API. Currently only the SQL API is supported with the Logic Apps connector. That's also why the partition key isn't being recognized. When setting up a SQL API container you are given the option to set your key, which you then use as I've described.


0 Votes 0 ·

Ahh! That’s the issue. So the solution is “ensure you are using the SQL API and make sure the partition key specified matches the value you are supplying”. Got it, thanks!

0 Votes 0 ·