Showing results for 
Search instead for 
Did you mean: 
Kudo Kingpin
Kudo Kingpin

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
Community Support

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 Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (1,721)