Logic Apps

Create Azure Logic App Using SQL Connectors

In BizTalk Server, SQL Adapter is the main component in order to communicate with the SQL Server. On the other hand, In Logic App we use the connector to communicate with the SQL server. In this tutorial, we will create a table in SQL Azure and perform read and write operations using the logic app.

Pre-requisites:

Create a table in SQL Azure:

  1. Login to Azure Portal.
  2. Click on SQL Database > Add.
  3. Enter a database name and select your subscription and resource group. Select Source as a Blank Database and click on Server. A new section named “Server” would appear. Click on Create a new Server or you can select an existing server.
    1. In case of a New Server, Enter any name in the Server name field and Server admin login field. Type any password and click on select. Please remember these credentials for now.
  4. Enter on Create button a new database would be created
  5. Click on your database > Overview > Tools > Query editor(Preview) and execute the following query in the query window.

CREATE TABLE ingredient ( ingredients INT primary key IDENTITY(1,1) NOT NULL,

ingredientName VARCHAR(50) NOT NULL,

ingredient price INT NOT NULL

);

INSERT INTO ingredient

( ingredientName, ingredientPrice)

VALUES

(‘Beef’, 3),

(‘Mango’, 2),

(‘Cheese’, 4);

Note: If you are unable to the execute query then click on Login at the top of the query window and provide your credentials which we created earlier.

Create another table with the same structure. So we can dump data from the ingredient table to a new table.

  1. Limitations:

The table must have an Identity column.

Logic App to import data from one table to another table:

  1. Go to the Azure portal again.
  2. From the left azure menu, choose New > Enterprise IntegrationLogic App.
  3. Add your Logic App name and select your subscription. Add new or use existing resource groups. Resource group helps you to manage all the related resources in one resource group. Mark the pin to the dashboard if you want and click on create.

  1. Select a blank logic app from the templates.
  2. Type SQL as a filter in the search box and select SQL Server – When an item is created
  3. If you are not connected already, click on Manually enter connection information. Enter all the connection information like undermentioned in the figure.

  1. Connection Name is just like connection string name. You can use the same connection in other logic apps.
  2. Once you entered the information, click on the create button.

  1. Now choose an action to dump data to a new table. At the bottom of the trigger, choose + New Step > Add an action.
  2. Provide the table name, and set the interval and frequency for recurrence. In the screenshot, I have set an interval of three minutes.

  1. Type SQL as filter again, and select SQL Server – Insert row from the action list.
  2. Select table name. All table columns would be shown as text boxes.

  1. Set value to text boxes, you can add static or dynamic values from previous actions.
  2. Now you can run this Logic App.

Author

Hassan Askari