Below are the components used in this document,
- Azure Cosmos DB
- Power Automate
Introduction
For details on Azure Cosmos DB, you can read the MS Doc
here. To get more details on how to insert data into Cosmos DB using Power Automate, you can refer to my previous article
here. Also you can read an article on how to read data from Cosmos DB using Power Automate by referring to my previous article
here.
Today we will see how to delete data from Cosmos DB whenever a button is clicked on a Power App Form. In my example, I already had Cosmos DB created. Below is the step by step way to delete data from Azure Cosmos DB.
Open Power Automate and create a new Flow
Note
In case you already have a Power Automate created, you can ignore this step.
Step 1
Browse to https://india.flow.microsoft.com and provide your Office 365 account details to login
Step 2
Select either a “Template” to start your Flow or you can search for the template. For my example I am selecting “Templates” from the left navigation highlighted with yellow in the below image and then selecting Power Apps button, as the trigger point for my Flow is a button click from Power Apps. You can select the template based on your requirements.
Step 3
Empty Flow will be opened,
Power Automate to delete data from Cosmos DB
Step 1
Name your Flow with an appropriate meaning. Add a new step, “Delete a document”, which will get all the rows from the Cosmos DB. In case you are not able to find it, then you should search for “Cosmos” and under that you will be able to select the “Delete a document” step as shown in the below screen shot.
Step 2
Now once you add the step, you will need to fill in the mandatory field values. The most important field is “Document ID”. This is the unique key to identify each row inside Cosmos DB.
Step 3
Save your Flow and test the flow, we should see data deleted from Cosmos DB.
That is it. I hope you have learned something new from this article and will utilize this in your work.