Parse text in Azure Logic Apps

logic app parse json example
logic app filter array
logic app formatdatetime
append to array variable logic app
logic app parse csv
logic app compose
logic app split string
logic apps create csv table

I want to create Azure Logic App which will constantly request a specific website on the Internet and parse received HTML.

I've created Logic App and set up interval and HTTP request action.

Which action should I choose as the next step for simple regex operation on HTML code?

What comes to my mind is creating Azure Function which will do the job, but I wonder if there is any other solution, more suitable for such task.

I want it the be simple as possible.


Edit:

Just found out some cool feature. Logic Apps contain some basic expressions for primitive types.

Unfortunetly it lacks of any regex or string.contains.

For now, I'll try with Azure Functions.

I've managed to solve my problem with use of Workflow Definition Language and building blocks provided by Azure.

The Azure Function idea was not that bad and would fit perfectly for any more complex case, but as I mentioned, I wanted it as simple as possible, so here it is.

This is how my flow looks now.

For sake of completeness, here is the flow in JSON format

{
    "$connections": {
        "value": {
            "wunderlist": {
                "connectionId": "/subscriptions/.../providers/Microsoft.Web/connections/wunderlist",
                "connectionName": "wunderlist",
                "id": "/subscriptions/.../providers/Microsoft.Web/locations/northeurope/managedApis/wunderlist"
            }
        }
    },
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "Condition": {
                "actions": {
                    "Create_a_task": {
                        "inputs": {
                            "body": {
                                "completed": false,
                                "list_id": 000000000,
                                "starred": true,
                                "title": "@{variables('today date')}"
                            },
                            "host": {
                                "connection": {
                                    "name": "@parameters('$connections')['wunderlist']['connectionId']"
                                }
                            },
                            "method": "post",
                            "path": "/tasks",
                            "retryPolicy": {
                                "type": "none"
                            }
                        },
                        "limit": {
                            "timeout": "PT20S"
                        },
                        "runAfter": {},
                        "type": "ApiConnection"
                    },
                    "Set_a_reminder": {
                        "inputs": {
                            "body": {
                                "date": "@{addHours(utcNow(), 3)}",
                                "list_id": 000000,
                                "task_id": "@body('Create_a_task')?.id"
                            },
                            "host": {
                                "connection": {
                                    "name": "@parameters('$connections')['wunderlist']['connectionId']"
                                }
                            },
                            "method": "post",
                            "path": "/reminders",
                            "retryPolicy": {
                                "type": "none"
                            }
                        },
                        "limit": {
                            "timeout": "PT20S"
                        },
                        "runAfter": {
                            "Create_a_task": [
                                "Succeeded"
                            ]
                        },
                        "type": "ApiConnection"
                    }
                },
                "expression": "@contains(body('HTTP'), variables('today date'))",
                "runAfter": {
                    "Initialize_variable": [
                        "Succeeded"
                    ]
                },
                "type": "If"
            },
            "HTTP": {
                "inputs": {
                    "method": "GET",
                    "uri": "..."
                },
                "runAfter": {},
                "type": "Http"
            },
            "Initialize_variable": {
                "inputs": {
                    "variables": [
                        {
                            "name": "today date",
                            "type": "String",
                            "value": "@{utcNow('yyyy/MM/dd')}"
                        }
                    ]
                },
                "runAfter": {
                    "HTTP": [
                        "Succeeded"
                    ]
                },
                "type": "InitializeVariable"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "parameters": {
            "$connections": {
                "defaultValue": {},
                "type": "Object"
            }
        },
        "triggers": {
            "Recurrence": {
                "recurrence": {
                    "frequency": "Day",
                    "interval": 1,
                    "startTime": "2017-08-01T23:55:00Z",
                    "timeZone": "UTC"
                },
                "type": "Recurrence"
            }
        }
    }
}

Perform operations on data, Must replicate parsing logic in multiple queries. Can share some logic through functions. Can create overhead when running complex logic  I want to create Azure Logic App which will constantly request a specific website on the Internet and parse received HTML. I've created Logic App and set up interval and HTTP request action. Which action should I choose as the next step for simple regex operation on HTML code? What comes to my mind is creating Azure Function which will do the

You can use inline code action in logic app to run javascript regex code (preview- May 2019) (Not supported on Flow).

Iniline Code

Logic App Inline Code Ref

Handle content types, Data operation code samples for Azure Logic Apps Compose; Create CSV table; Create HTML table; Filter array; Join; Parse JSON; Select  Basic knowledge of using Azure Logic App with dynamic content as well as to send email. You can follow this step-by-step guidance to ramp up. Basic knowledge of SecurityAlert table that stores alert from Azure Security Center, Azure Sentinel or so on. Parse JSON action. Let’s pick a sample alert from SecurityAlert table.

You're probably on the right track. An Azure Function would be the most appropriate way to implement this right now. An API App is an option but that's a heavier platform than you need.

Parse text data in Azure Monitor logs, Parse Emails to be used in a Azure Logic Apps. Once a run is complete, the app that I use (Runmeter) generates an email with a link to the run  Test your logic app. To confirm whether the Parse JSON action creates the expected results, send yourself a notification that includes output from the Parse JSON action. In your logic app, add an action that can send you the results from the Parse JSON action. In that action, click anywhere you want the results to appear.

create an Azure Function along the lines of:

{

log.Info("C# HTTP trigger function processed a request.");

// Get request body

dynamic data = await req.Content.ReadAsAsync<object>();



// Set name to query string or body data

string input = data?.input.ToString();

var regexJson = data?.regexList;

var regexes = regexJson.ToObject<List<RegexReplace>>();



foreach (var regex in regexes) 

{

    var re = Regex.Replace(regex.Regex, "\\\\","\\");

    var replace = Regex.Replace(regex.Replace, "\\\\","\\");

    input = Regex.Replace(input, "\\\"","\"");

    input = Regex.Replace(input, re, replace);

}



input = Regex.Replace(input, "[\\r\\n]", "");



return data.regexList == null

    ? req.CreateResponse(HttpStatusCode.BadRequest, "Please pass a name on the query string or in the request body")

    : req.CreateResponse(HttpStatusCode.OK, input, "application/json");

}

public class RegexReplace

{

public string Regex { get; set; }

public string Replace { get; set; }

}

Reference guide for functions in expressions, This blog will brief on Azure Logic App Expressions and a short introduction about Workflow Definition Language in Azure Logic Apps. convertFromUtc – Convert a timestamp from Universal Time Coordinated (UTC) to the  # Parse Emails to be used in a Azure Logic Apps. Once a run is complete, the app that I use (Runmeter) generates an email with a link to the run data (GPX, CSV, KML File) in the following format: The pieces of data that we'd like to extract are the kml, gpx, csv URLs and the last piece of the Explorer Link URL.

This is my function to use for replacing text in a string. this is reusable and the approach can be used for many similar type of aspects of working in Logic Apps:

using System.Net;

public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log)
{
    dynamic data = await req.Content.ReadAsAsync<object>();
    string removeme = data?.removeme;
    string replacewith = data?.replacewith;
    string value = data?.value;

    return req.CreateResponse(HttpStatusCode.OK, value.Replace(removeme, replacewith));
}

I would then post an object like this from my logic app:

{
    "removeme": "SKU-",
    "replacewith": "P-",
    "value": "SKU-37378633"
}

... to get the result: "P-37378633"

Code samples for using data operations, This article is about using function expressions which helps to enhance your Azure Logic App with an interactive session by Steef-Jan Wiggers. Parse CSV allows you to read a CSV file and access a collection of rows and values using Microsoft Flow. It is quite easy to work with CSV files in Microsoft Flow with the help of Plumsail Documents.

Tip 37, Expressions actions in Microsoft Power Automate or Azure Logic Apps. We will use regular How to use regex test to check if text matches specific pattern. Translating JSON messages with Logic Apps. One of the key components of an integration platform is message translation. The Microsoft Azure iPaaS Logic Apps service offers message translation with the out of the box ‘compose’ operation. Alternatively, message translation can be achieved with Liquid transforms.

Azure Logic App Expressions, To create a logic app select “New” in the Azure Portal and search for “Logic App”. Fill in the required fields, and click the “Create”-button. When the Logic App is created, we have to link the Integration Account created before, to the newly created Logic App.

Use Azure Logic Apps Function Expressions, Logic Apps stores and handles any request with the application/json content type as a JavaScript Notation (JSON) object. By default, you can parse JSON content without any casting. To parse a request that has a header with the "application/json" content type, you can use an expression.

Comments
  • Azure function would be my suggestion. You could also build a custom connector but that would likely be more overhead.
  • As you can see, I used "contains" function on string object.
  • you say that a function was going to be too much yet you used it anyway?
  • I havent used the azure function. Good job resurecting year old answer btw.