Skip to content

Logic Apps Examples

Ensure you have completed the initial set up of your environment before trying these examples.

Note

The initial set up should be performed only once per resource group/subscription to avoid duplicates.

Two types of examples have been provided:

  1. Create Logic Apps using different connectors:
  2. Create Logic Apps by using Retain templates:

Create a Logic App resource

  1. Sign in to your Azure portal with your Azure account
  2. Click Create a resource

  3. Enter Logic App in the search box and then select Logic apps

  4. Click Create on the logic apps page

  5. Select your Azure subscription name and Resource Group. You create your logic app and related resources in the Azure resource group. This name must be unique across regions and can contain only letters, numbers, hyphens (-), underscores (_), parentheses (()), and periods (.)

  6. Enter a name for your Logic App. This must be unique across regions and can contain only letters, numbers, hyphens (-), underscores (_), parentheses ((, )), and periods (.)
  7. Select the Region. This is the Azure datacenter region for storing your app's information
  8. Select Consumption as your Plan type. Plan type property specifies the logic app type and billing model to use
  9. Zone redundancy section appears after selecting Plan type. Select Enabled. To read more, see set up zone redundancy
  10. For a quick start, set Enable log analytics to No
  11. Click Review and Create and then click Create on the validation page
  12. You will get a message Deployment succeeded and an option Go to resources on the top right corner

After this point, you can proceed to create a resource.

Query specific fields of the Job table by using Retain API

This example queries the following fields from the Job table: job_guid, job_description, job_code, job_start and job_end. It uses the query one or more tables api in order to do this.

The following screenshot shows the high-level example workflow:

After setting a recurrence trigger, the following three variables are initialized: Retain Cloud Environment, Retain Cloud Tenant and Retain Cloud Table. The Bearer token is then obtained. The Bearer token is then stored in a variable called BearerToken. In the final step, the POST method of the following API is used to get the records. All the variables that have been stored (Retain Cloud Environment, Retain Cloud Tenant, Retain Cloud Table and BearerToken) are then passed in the body.

The detailed steps are given below:

After ensuring that you have completed the initial set up and after creating a Logic App resource:

  1. Click Go to resources or find and select your logic app resource by typing the name in the Azure search box
  2. Click + blank Logic App

  3. You can now either set up a schedule to run at periodic intervals or a trigger to run when specific events occur

  4. Select All and then Schedule
  5. Select Recurrence

  6. Enter the Interval and select the Frequency, for example, once every day

  7. Click New Step and choose an Operation

  8. Select Variables and then Initialize variables

  9. Enter the values shown above. You may change the title by selecting the 3-dot menu

  10. Click +New step

  11. Follow the same process to enter values for Retain Cloud Tenant

  12. Click +New step
  13. Get bearer token and enter information as shown below; URL should have been provided to you by the delivery team; Content-Type: application/json; charset=utf-8

  14. Initialize the bearer token variable and then pass the Body (dynamic content) as the value

  15. The final step is to get the records from the Job table

Import data from CSV file into Retain

This is a standard logic app which fetches data from a CSV file and transforms and upserts the data into Retain Cloud. The following screenshot shows the high-level example workflow:

Note: The following example uses Azure Resource Managemener (ARM) templates to help you get set up. If you're using or editing these files, using Visual Studio Code and installing the ARM Tools extension is recommended.

Template to use

In order to import data from a CSV file into Retain:

  1. If you haven't, complete the initial set up
  2. Deploy the following template:

Transform CSV to JSON: use logic-importcsv-template.json (download) template.

Parameters

  • Region: auto-populated based on the resource group location
  • Logic_App_name: name chosen by the user following environment conventions
  • CSV_file_path: CSV file path in the blob container including the container name. Can be changed later in the Logic App editor
  • AF_Access_Key: access key to grant permission to the 'convert CSV to JSON' Azure function. Can be fetched/created from the Azure Functions key store. Contact our team if you require further help

Import data from SQL Server database into Retain

This is a standard logic app which fetches data from SQL Server and transforms and upserts the data into Retain Cloud. The following screenshot shows the high-level example workflow:

Note: The following example uses Azure Resource Managemener (ARM) templates to help you get set up. If you're using or editing these files, using Visual Studio Code and installing the ARM Tools extension is recommended.

Template to use

In order to import data from a SQL Server database into Retain:

  1. If you haven't, complete the initial set up
  2. Deploy the following template:

logic-importsql-template.json (download) template

Parameters

  • Region: auto-populated based on the resource group location
  • Logic_App_name: name chosen by the user following environment conventions
  • Setup_SQL_connection: true/false. If a SQL connection is already set up then a new one is not needed and should be false, otherwise true
  • Sql_Server_name, Database_name, User_name and Password: database credentials. Once created, the SQL API Connection credentials can be changed through the Azure portal
  • Table_or_view_name: table or view to fetch data from. Can be changed later in the Logic App editor