Showing results for 
Search instead for 
Did you mean: 
Level 8

Flow broke after it was working - InvalidTemplate on Cosmos DB connection

Hi all, 


This is most strange. I have this flow that has been working fine for some time. 

It was made primarily to sync SalesForce data to some SQL ghost tables.

I added some Cosmos DB actions to start ghosting the same data in Cosmos DB in SQL mode, to better understand and explore it. 


Initially the Flow was working with no issues, and I have ran it several times. 


The last time I tried to trigger it though, it failed at Cosmos DB. 


The error is: 


InvalidTemplate. Unable to process template language expressions in action 'Query_Cosmos_SF_accounts' inputs at line '1' and column '2734': 'The template language expression 'json(decodeBase64(triggerOutputs().headers['X-MS-APIM-Tokens']))['$connections']['shared_documentdb']['connectionId']' cannot be evaluated because property 'shared_documentdb' doesn't exist, available properties are 'shared_salesforce, shared_sql'. Please see for usage details.'.


It seems at the core of the Flow it lost the Cosmos DB connection, as it only lists 'shared_salesforce, shared_sql' as available properties.


I tried adding a redundant Cosmos DB connection. 

The 'Connections' panel of the flow details correctly show the connections for Salesforce, SQL and 2 Cosmos DB connections. 

I tried changing the first Cosmos DB action to use the new Cosmos DB connection to see if it was a connection problem.


However, the error message remains the same. 


I tried exporting and updating the Flow from the exported one. 


However, the error message remains the same. 


Recreating the Flow from scratch would be super time-consuming, as it is a complex flow with many steps and branches using advanced expressions. 


Anyone can shed some light on the subject? 



Community Support Team
Community Support Team

Re: Flow broke after it was working - InvalidTemplate on Cosmos DB connection

Hi @TiagoFreire,


Could you please share a screenshot of the configuration of your flow?

Which action run failed in the flow? 

Could you please delete the action and then add it again to see if the issue still exists?

Also could you please create a new connection to the action?


Best regards,



Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.



Helpful resources


Power Platform Online Conference

Speakers, submit your sessions now! Call for speakers ends Feb. 10!


New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!


Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!


Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!


Microsoft Learn

Learn how to build the business apps that you need.


Power Platform World Tour

Find out where you can attend!


Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (3,871)