Monday 3 December 2018

Create a logic apps for receiving a json array (Employee records) using Rest end point and save each record in Azure SQL database

Create a logic apps for receiving a json array (Employee records) using Rest end point  and save each record in Azure SQL database .
Create Logic Apps
Create a Azure SQL database and database server.
3 resources created in your resource group now
Create Table in your database using Azure Query editor
Query:
CREATE TABLE [dbo].[Employee](
      [ID] [int] IDENTITY(1,1) NOT NULL,
      [UserId] [nvarchar](50) NULL,
      [JobTitleName] [nvarchar](50) NULL,
      [FirstName] [nvarchar](50) NULL,
      [LastName] [nvarchar](50) NULL,
      [PreferredFullName] [nvarchar](50) NULL,
      [EmployeeCode] [nvarchar](50) NULL,
      [PhoneNumber] [nvarchar](50) NULL,
      [EmailAddress] [nvarchar](50) NULL
     
 CONSTRAINT [PK_Employee] PRIMARY KEY CLUSTERED
(
      [ID] ASC
))
Design Logic App using a blank logic app
We are using HTTP end point as trigger so that you can trigger or call your logic apps through a URL.
Employess sample JSON Payload
{
"Employees" : [
{
"userId":"rirani",
"jobTitleName":"Developer",
"firstName":"Romin",
"lastName":"Irani",
"preferredFullName":"Romin Irani",
"employeeCode":"E1",
"region":"CA",
"phoneNumber":"408-1234567",
"emailAddress":"romin.k.irani@gmail.com"
}
]
}
Next choose foreach control
Now add action inside foreach loop (SQL Connection).
Map json with Table Column
Save the logic app .
It will generate the end point for your logic app .
Test Logic app using postman (must set content type as json ).
Create API gateway for logic apps using Azure API Management.
Create API in API management and point to logic apps

2 comments:

  1. Great Article Mohit... Thanks for sharing

    ReplyDelete
  2. Thanks for sharing the information in Azure using Microsoft's solution and its logical apps helpful in made of architectures. Microsoft azure become the best cloud computing in recent days

    ReplyDelete