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!

Design a site like this with WordPress.com
Get started