4

The Azure Logic Apps action "Get Blob Content" doesn't allow us to set the return content-type.

By default, it returns the blob as binary (octet-stream), which is useless in most cases. In general it would be useful to have text (e.g. json, xml, csv, etc.).

I know the action is in beta. Is that on the short term roadmap?

4 Answers4

6

Workaround I found is to use the Logic App expression base64ToString.

For instance, create an action of type "Compose" (Data Operations group) with the following code:

        "ComposeToString": {
            "inputs": "@base64ToString(body('Get_blob_content').$content)",
            "runAfter": {
                "Get_blob_content": [
                    "Succeeded"
                ]
            },
            "type": "Compose"
        }

The output will be the text representation of the blob.

4

So I had a blob sitting in az storage with json in it. Fetching blob got me a octet back that was pretty useless, as I was unable to parse it.

BadRequest. The property 'content' must be of type JSON in the 'ParseJson' action inputs, but was of type 'application/octet-stream'.

So I setup an "Initialize variable", content type of string, pointing to GetBlobContent->File Content. The base64 conversion occurs under the hood and I am now able to access my json via the variable.

No code required.

JSON OUTPUT...

enter image description here

FLOW, NO CODE...

enter image description here

Enjoy! Healy in Tampa...

Joe Healy
  • 5,349
  • 3
  • 32
  • 54
1

After fiddling much with Logic Apps, I finally understood what was going on.

The JSON output from the HTTP request is the JSON representation of an XML payload:

{
  "$content-type": "application/xml",
  "$content": "77u/PD94bWwgdm..."
}

So we can decode it, but it is useless really. That is an XML object for Logic App. We can apply xml functions to it, such as xpath.

1
  1. You would need to know the content-type.
  2. Use @{body('Get_blob_content')['$content']} to get the content part alone.
Shidin
  • 41
  • 4