Adding content to a database
Now that you have configured a server, a database, and a table with columns, you get to see all the pieces working together. In this section, you'll create a flow, execute it, and then verify that it wrote the data successfully.First, let's create a flow so that we can add content.
Creating the flow
To verify that you've configured database connectivity, we'll walk through creating a sample button or instant flow so that we can post data to the database. Follow these steps to create the flow:
- From the Power Automate web portal (https://make.powerautomate.com), select Create.
- In the Start from blank section, select Instant cloud flow.
- Enter a name for the flow, and then select Manually trigger a flow as the trigger type.
- Click Create.
- Add an action.
In the search box, enter
SQL insertand then select the Insert row (V2) action:
Select the Server name, Database name, and Table name you created in the Creating a database table section.
Once you've selected the items from your connection, the action will update to display all the available columns under the Advanced parameters section. Select all of the parameters.
After selecting the column names, add some test data, as shown in Figure 13.16:
- Click Save.
The flow is now ready to test.
Executing the flow
Use the process you learned about in Chapter 5, Creating Button Flows, to execute the flow. As a refresher, you can follow these steps:
- On the Maker canvas page, click Test.
- Select the Manually radio button and click Test.
- On the Run flow flyout panel, click Continue.
- Click Run flow.
- Click Done.
With that, the flow has been successfully executed.
Verifying the flow
You can check whether the content was written to the flow by examining the flow's run history or by querying the database table in SQL.
Reviewing the run history
The easiest and quickest way to verify whether the flow is successful is to examine its run history. The flow's run history will show the steps that were performed during the flow's execution. You can review the run history for the flow by using the following process:
- Expand the ellipsis for the flow and then select Run history.
- Select the date and time of the run to display the history.
- Expand the SQL action to view the data:
The expanded action will show the data that was inserted into the table.
Reviewing the SQL data
You can also use the process you used earlier under the Creating a database table section to validate data. Using the SQL Query editor, you can also view the newly added data. To view the SQL data directly, follow these steps:
- From the Azure portal (https://portal.azure.com), navigate to Azure SQL | SQL databases and select the database.
- Select Query editor (preview). Enter your login credentials to access the database, if necessary, and then click OK.
- In the Query editor (preview) blade, expand Tables, select dbo.Customers, and then click the ellipsis for the table. Click Select Top 1000 Rows.
- Compare the data in the Results pane to the values you entered in the Creating the flow section.
No matter how you choose to verify that the flow was executed successfully, you should be able to see the same data.