question

tanishahudson-2078 avatar image
0 Votes"
tanishahudson-2078 asked SatishBoddu-MSFT commented

Logic App to push data from Cosmosdb into CRM and performing updates

I have created a logic app with the goal of pulling data from a container within cosmosdb (with a query), looping over the results and then pushing this data to CRM. When the data is pushed to CRM, an ID will be created and I wish to then update cosmosdb with this new ID. Here is what I have so far:

13648-image.png


This next step is querying for the data within our cosmosdb database and selecting all IDS with a length that is greater than 15. (This tells us that the ID is not yet within the CRM database)



13667-image.png















Then we loop over the results and push this into CRM (Dynamics365 or the Common Data Service)




13649-image.png







Dilemma: The first part of this process appears to be correct, however, I want to make sure that I am on the right track with this. Furthermore, once the data is successfully pushed to CRM, CRM automatically generates an ID for each record. How would I then update cosmosDB with the newly generated IDs?



13650-image.png



Any suggestion is appreciated

Thanks


azure-logic-appsazure-cosmos-db
image.png (38.0 KiB)
image.png (56.0 KiB)
image.png (40.8 KiB)
image.png (58.2 KiB)
· 2
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 @tanishahudson-2078, Thanks for reaching out to us, we are looking into this. Could you please let us know what Documents/Links have you referred in this matter?

0 Votes 0 ·

1 Answer

SatishBoddu-MSFT avatar image
1 Vote"
SatishBoddu-MSFT answered SatishBoddu-MSFT commented

Referencing the Answer provided by Microsoft Team on Stackoverflow:

I see a red flag in your approach here with this query with length(c.id) > 15. This is not something I would do. I don't know how big your database is going to be but generally not very performant to do high volumes of cross partition queries, especially if the database is going to keep growing.

Cosmos DB already provides an awesome streaming capability so rather than doing this in a batch I would use Change Feed and use that to accomplish whatever your doing here in your Logic App. This will likely give you better control of the process and likely allow you to get the id back out of your CRM app to insert back into Cosmos DB.

Because you will be writing back to Cosmos DB, you will need a flag to ignore the update in Change Feed when the item is updated.

Please refer to Change feed in Azure Cosmos DB


· 1
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 @tanishahudson-2078,Just checking back, could you please let us know if you need further help in this matter.

0 Votes 0 ·