Retrieve data from Azure Cosmos DB using Power Automate

Let’s learn about how to fetch data from Cosmos DB using Power Automate and push into Dynamics CRM.

For retrieving the data from Azure Cosmos DB we will need a few details from Azure:

1. URI
2. Primary Key

Figure 1: Azure Key for Cosmos DB connectivity

Let’s jump to Power Automate and start adding the necessary component for achieving this activity.

I have used a manual trigger for reading the data from Azure Cosmos DB and pushing it into Dynamics CRM.
Chose an action –> Search for Azure Cosmos DB, then under action select Get all documents.

Figure 2: Creating Flow using Azure Cosmos DB component

We will use the Azure Cosmos DB detail for establishing the connection as shown in the below image. Access Key to your Azure Cosmos DB account here we have to enter Primary Key as shown under Figure 1. Hit Create button.

Figure 3: Establishing connection with Cosmos DB
Figure 4: Select the DB and table

Select the desired database under the Database ID and table under the Collection ID field and hit the + New step button.

After the connection has been successfully established. Search for Parse JSON and add Documents under the Content field. Paste the JSON output under the schema. Hit the + New step button.

Figure 5: Parse JSON as an output

Next, we will search for a control Apply to each.

Figure 6: Add control Apply to each

Under, Select an output from previous steps field pastes the Body from the Dynamic content and click Add an action button.

Figure 7: Add Body from Dynamic content
Figure 8: Search for Common Data Service(current environment), Action: Create a new record

The above action is needed as it will allow us to map the value coming from JSON to be stored inside Dynamics CRM entity attributes. 

Figure 9: Mapping CRM attributes with the output columns.

Now, we need to test our flow with a few more clicks to be performed. Click on the Test button which would appear on the right top of the screen.

Figure 10: Test Flow

The flow will start executing, once the flow has run successfully we will get the below screen. 

Figure 12: Flow execution

Now, go into CRM and we will see the records have been created under the expected entity.

Hope this help anyone!

Azure Logic Apps

What is Azure Logic Apps?

Logic Apps is a cloud service which is managed by Microsoft Azure. It helps us in automating the business processes.

Why use Logic Apps?

Logic apps is very simple and has a very powerful workflow which is managed by Microsoft Azure. It helps in building a server less architecture, so the user does not have to worry about hosting, scaling or managing the solution. Azure Logic Apps contains 200+ connectors with it and provide users the facility to go ahead and implement another new connector if needed.

Logic apps has a very powerful architecture for logging and tracking the run history, trigger history and performance. All these activities can be access from a governance dashboard in Azure.

Another important advantage of Logic Apps is that “you pay only for what you use”. Pricing is done based on the number of actions happening within the Logic Apps, if the Logic Apps is sitting ideal there won’t be any charges incurred.

Components of Logic Apps

  1. Trigger
  2. Actions
  3. Connectors
  4. Flow Controls

How Logic Apps works?

Logic Apps works as a workflow which trigger when a specific event occurs or when any criteria is met.

Logic App can be scheduled as well so that it triggers on a time interval. User need to use a Schedule trigger.

Whenever the Logic App is triggered, the set of action associated to it also gets executed. Actions can include multiple conditions like switch statement, Looping, If and else condition or branching.

Example: Whenever a trigger detects an event which matched the trigger criteria, it fires and run the workflow actions.