Parse text in Azure Logic Apps

Viewed 17513

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.

5 Answers

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"

Related