user195166
user195166

Reputation: 439

LogicApps scenario log on, download, zip

I access a 3rd party website using forms authentication (username and password). Once logged on I make a call to a HTTP endpoint and receive XML in the body. The XML contains 1000 XML elements. Within each element there is a text value, a code. For each of these codes I make a further call to a different HTTP endpoint. The response is more XML. When all 1000 responses have been received I would like to add all the XML responses as files to a zip container and make it available for download.

I would like to see how LogicApps could do this as quickly as possible.

Upvotes: 0

Views: 93

Answers (1)

bc3tech
bc3tech

Reputation: 1332

  1. Make the call to the first HTTP endpoint (auth set to basic auth with user/pass inputted)
  2. Use the xpath(xml(<body var here>), '//elementNameHere') expression on the Body of the result from the call to get all the elements of the return value that have the code in it
  3. Foreach over this return value and
    1. make the HTTP call
    2. append the result to an array variable, or concat on to a string variable.
  4. Submit this value to blob storage

Because you're messing w/ vars in the foreach loop, though, you'll have to do it sequentially (set concurrency control on the Foreach Loop to 'on' and '1') else you could end up with a bad result.

I don't know of a way to "zip contents" here so you may have to send the result to an Azure Function that uses a .Net zip lib to do the work (or js zip lib, whatever your flavor) and does the put to blob storage for you.

This would also all be much easier in Durable Functions land, I encourage you to look in to that if you're so inclined.

One mild alternative you might consider is for step 3.2, instead upload that result to a blob storage container, then make the entire container available for download via an Azure Function call which gets the container & zips up the contents (or does the Blob Storage URL for a container do this for you already? not sure)

Upvotes: 2

Related Questions